Spudinski Posted February 11, 2012 Posted February 11, 2012 (edited) 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'); raintpl::configure( array( '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 February 11, 2012 by Spudinski Quote
Neon Posted February 11, 2012 Posted February 11, 2012 Started using Smarty. Always have. It has its downsides, but once you master and learn Smarty it can be used very well. I have also used my own classes, that just simply str_replaces() vars and isn't very powerful. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.