Part of the EllisLab Network
   
1 of 13
1
Template Library Version 1.4.1
Posted: 02 November 2008 01:13 AM   [ Ignore ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2916
Joined  07-27-2006

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:

$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.

 Signature 

Check out the Template Library
Oh yeah, I tweet, too (regarding CodeIgniter on occassion).

Profile
 
 
Posted: 02 November 2008 12:24 PM   [ Ignore ]   [ # 1 ]  
Grad Student
Rank
Total Posts:  31
Joined  08-30-2008

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

Profile
 
 
Posted: 04 November 2008 02:12 PM   [ Ignore ]   [ # 2 ]  
Grad Student
Rank
Total Posts:  58
Joined  07-14-2008

Hello Colin

Great stuff love it :D

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

config.php

$template['default']['regions'] = array(
   
'header' => array('view'=>'my_view_file')
);

Or something similar?

Profile
 
 
Posted: 04 November 2008 04:03 PM   [ Ignore ]   [ # 3 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2916
Joined  07-27-2006

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.

 Signature 

Check out the Template Library
Oh yeah, I tweet, too (regarding CodeIgniter on occassion).

Profile
 
 
Posted: 04 November 2008 06:52 PM   [ Ignore ]   [ # 4 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2916
Joined  07-27-2006

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:

$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.

 Signature 

Check out the Template Library
Oh yeah, I tweet, too (regarding CodeIgniter on occassion).

Profile
 
 
Posted: 04 November 2008 11:17 PM   [ Ignore ]   [ # 5 ]  
Lab Technician
RankRankRankRank
Total Posts:  1040
Joined  06-19-2007

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

 Signature 

My new therapist is working with me every day, the third one gave up… ohh

Profile
 
 
Posted: 04 November 2008 11:37 PM   [ Ignore ]   [ # 6 ]  
Lab Technician
RankRankRankRank
Total Posts:  1040
Joined  06-19-2007

I was thinking along the lines of something as simple as this:

//  $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.

 Signature 

My new therapist is working with me every day, the third one gave up… ohh

Profile
 
 
Posted: 05 November 2008 01:10 AM   [ Ignore ]   [ # 7 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2916
Joined  07-27-2006

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..

 Signature 

Check out the Template Library
Oh yeah, I tweet, too (regarding CodeIgniter on occassion).

Profile
 
 
Posted: 05 November 2008 01:16 AM   [ Ignore ]   [ # 8 ]  
Lab Technician
RankRankRankRank
Total Posts:  1040
Joined  06-19-2007

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

 Signature 

My new therapist is working with me every day, the third one gave up… ohh

Profile
 
 
Posted: 05 November 2008 01:20 AM   [ Ignore ]   [ # 9 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2916
Joined  07-27-2006

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.

 Signature 

Check out the Template Library
Oh yeah, I tweet, too (regarding CodeIgniter on occassion).

Profile
 
 
Posted: 05 November 2008 03:49 AM   [ Ignore ]   [ # 10 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  131
Joined  06-06-2008

Colin I would also be interested in the idea of a “minifier” plug-and-play solution. Would come in most handy as the company I’m working for is looking to restructure their system, and the possibility of using CI is very high, which would include your Template library as it has a plug-and-play system that integrates Smarty.

Keep us posted please smile

 Signature 

Milos Dakic
JustHost - world class hosting
Library: Events Library

Profile
 
 
   
1 of 13
1
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 119762 Total Logged-in Users: 29
Total Topics: 125937 Total Anonymous Users: 3
Total Replies: 662564 Total Guests: 374
Total Posts: 788501    
Members ( View Memberlist )
Newest Members:  frostiexadamsmithdj1White HattkatimariedelcaljeffewensJuan AlumadontheobaldBCFEA2FBS