Jump to content

Which template engine do you use?


Which template engine do you use?  

10 members have voted

  1. 1. Which template engine do you use?

Recommended Posts

Yes, smarty is the most popular, so I'm pretty sure it will win.

But, there are plenty of other options(some better) available.

So which template engine do you rely on the most, and why?

My choice is RainTPL. It's very compact, just over 1,000 lines in one file, and supports the things I use most in template engines, like caching.

It's also very efficient to work with for me, as it's very flexible. I can generate an infinite amount of templates in one go.

The draw back, is the caching. It's not very, "timely". And thus, creates a bottleneck in your script, where it appears the application is lagging behind.

Sample template:

<p>Hello there, {function="ucwords($name)"}!</p>


Sample construct:

// setup templating
       require_once($c['paths']['vendor'] . 'raintpl/rain.tpl.class.php'); 
                   'base_url'  => null,
                   'tpl_dir'   => ($c['paths']['tpl'] . $c['tpl']['cur']),
                   'cache_dir' => ($c['paths']['tpl'] . $c['paths']['tmp'])
       if(!$cache = $tpl_main->cache($page, 60, 1)) {
           $tpl_main->assign('name', $user_name);
           $content = $tpl_main->draw('template', true);
       } else $content = $cache;

       // $content is the template, ready to be buffered out.


Quite easy.

Edited by Spudinski
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...