Welcome Guest, Not a member yet? Register   Sign In
Template Library Version 1.4.1
#1

[eluser]Colin Williams[/eluser]
Template Library Version 1.4.1 has been released.

-------------------------------------------------------------------------------------

Visit the Template Library Homepage

View the Change Log

Still using Template 1.4? See the Ignited Code thread covering Template 1.4

-------------------------------------------------------------------------------------

What's New in Version 1.4.1?

Version 1.4.1 is mostly a maintenance release, fixing comment and documentation typos. In addition, the 1.4.1 download now ships with its documentation. And finally, the Template class was renamed to work more like a core library so you can extend/overload/replace it in your application libraries folder, among other things.

-------------------------------------------------------------------------------------

The Template library, written for the CodeIgniter PHP-framework, is a wrapper for CI’s View implementation. Template is a reaction to the numerous questions from the CI community regarding how one would display multiple views for one controller, and how to embed “views within views” in a standardized fashion. In addition, Template provides extra Views loading capabilities and shortcuts for including CSS, JavaScript, and other common elements in your final rendered HTML.

Using Template looks like this:

Code:
$this->template->write('title', 'Introduction to Template');
$this->template->write_view('content', 'blog/posts', $this->blog->get_posts());
$this->template->render();

Look interesting? Head over to the Template Library Homepage to begin using Template in your next CodeIgniter application.
#2

[eluser]ConnorD[/eluser]
Colin,

I have to say that after using your Template library the last hour or so, I really love it. It will make CI development much easier for dynamic sites. I am currently working on a website that requires CMS-like admin functionalities, and this library should help me a lot so that I can work with views much more efficiently and dynamically.

Connor
#3

[eluser]warrennz[/eluser]
Hello Colin

Great stuff love it Big Grin

Just wondering if there a way to set a region's default to a view file?

config.php
Code:
$template['default']['regions'] = array(
   'header' => array('view'=>'my_view_file')
);

Or something similar?
#4

[eluser]Colin Williams[/eluser]
That's been requested a lot, warrennz. And although I don't particularly like the idea, I might as well get it in place for people who do like the idea. I always suggest that you write the view to the region in either the Controller constructor, a parent controller, hook, or some other bootstrapping process.
#5

[eluser]Colin Williams[/eluser]
Okay.. I have "views embedding" in place for version 1.5

This new feature lets you embed views with an XML-style tag that can appear anywhere in your content:

Code:
$this->template->write('region', '<view src="sidebar/login" />')

So, you could configure the content of a region to embed a view in this way. I think this opens up a lot of opportunities.

There are security implications, too. So, I'm not 100% sold yet.
#6

[eluser]Randy Casburn[/eluser]
Hey Colin, I finally got around to looking at your Template Library.

I have a "will you consider" question. You know I use ExtJS. Those of us that rely extensively on a lot of JS use many (many, many, sometimes) JS files. We usually employ some method of concatenating all these files prior the being served out to the browser. A lot of the time, that includes the CSS files too. Let's just say we like to minimize the TCP connections required by the browser.

So, will you consider a straight, no frills concentrator for JS files and CSS files?

Thanks for your consideration,

Randy
#7

[eluser]Randy Casburn[/eluser]
I was thinking along the lines of something as simple as this:

Code:
//  $file array array('/assets/myFile.js','/assets/myOtherFile.js')
//  $type string 'js' OR 'css'
function _add_assets($files, $type)
{
    $file = realpath(trim($file, "/"));
    foreach($files as $file)
    {
        if (is_file($file) && is_readable($file))
        {
            $assets[$type] = file_get_contents($file);
        }
    }
    return implode(array_values($assets[$type]), "\n");
}

thoughts?

Randy

[edit] I suppose I hit the post button too fast. The rest of the story would be outputting a MIME header and then sending this content as a single JS file for instance.

My hidden agenda is that I intend to cache this output and serve the cache. But that isn't for your Template to do.
#8

[eluser]Colin Williams[/eluser]
Randy,

I teetered on the decision to add the js and css methods for the very reason that I knew a greater scope of functionality would be desired. And you're dead on about it seeming to fall out of the realm of the Template class.

My recommendation at this point remains to use other compactors or asset libraries to get that desired effect, and then use one of Template's methods to include the references to the compacted files. This is partly why I decided to use $_styles and $_scripts (note the underscores) as the 'regions' for Template's add_css() and add_js() methods, respectively.

One other thing I want to do is look into the popular libraries/scripts specialize in that kind of compacting, and, like I did with parsers, make a sort of plug-in system that would manifest itself like parsers: Just some additional configuration settings.

A lot up in the air on it still..
#9

[eluser]Randy Casburn[/eluser]
In sync with you on this. If anything comes to pass I'll let you know. Certainly don't want you to duplicate effort. A pluggable interface would be ideal. With that in mind, I'm working with jsmin at the moment, that might be the JS answer. The CSS thing is simple concat as far as I'm concerned.

Will let you know.

Thanks for the consideration.

Randy
#10

[eluser]Colin Williams[/eluser]
Yeah, I do want to look into those things.. because there's a lot that can be done to optimize JS and CSS beyond concatenating them, as you alluded to.

What I might do in the end is feel out the top JS and CSS optimizers and offer interfaces to those exclusively, or maybe a group for each.




Theme © iAndrew 2016 - Forum software by © MyBB