CodeIgniter Forums

Full Version: Smarty in CI
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2

El Forum

[eluser]CodeIgniterNewbie[/eluser]
If I am both the developer and designer of a site, is there any benefit to using a template engine like Smarty in an MVC framework like CI? Doesn't the "V" provide enough separation of concern?

El Forum

[eluser]xwero[/eluser]
The benefit of a template engine for a designer is that he/she sees all the html in wysiwyg mode. If you have php in your views they will only see it as one tag and if the php code has html elements the design could break because they didn't see it.

So if you are developer and designer a template engine isn't necessary, you can always add it later.

El Forum

[eluser]CodeIgniterNewbie[/eluser]
Aside from trying to keep it less confusing for the designer, isn't there a benefit there somehow?

El Forum

[eluser]Sam Dark[/eluser]
Not really…

El Forum

[eluser]CodeIgniterNewbie[/eluser]
How about these benefits listed on Smarty's site (see: http://www.smarty.net/rightforme.php):

Caching: Smarty provides fine-grained caching features for caching all or parts of a rendered web page, or leaving parts uncached. Programmers can register template functions as cacheable or non-cachable, group cached pages into logical units for easier management, etc.

Security: Templates do not contain PHP code. Therefore, a template designer is not unleashed with the full power of PHP, but only the subset of functionality made available to them from the programmer (application code.)

Compiling: Smarty compiles templates into PHP code behind the scenes, eliminating run-time parsing of templates.

Performance: Smarty performs extremely well, despite its vast feature set. Most of Smarty's capabilities lie in plugins that are loaded on-demand. Smarty comes with numerous presentation tools, minimizing your application code and resulting in quicker, less error-prone application development/deployment. Smarty templates get compiled to PHP files internally (once), eliminating costly template file scans and leveraging the speed of PHP op-code accelerators.

El Forum

[eluser]Sam Dark[/eluser]
Caching
Yes. Smarty's caching is very flexible. I want to see something like it in CI.

Security
If you are serious about letting designer to edit templates — yes. It's a benefit. But I don't think it's a good idea.

Compiling and Performance
Yes, it comples a lot of templates to one php-template. But even using this it checks if template compliled and loaded itself. So there is still some notable overhead.

El Forum

[eluser]xwero[/eluser]
Caching is provided by CI.
Security you don't need because you are the designer and developer.
If you add smarty to CI you create an extra layer for your view files, pure php is always faster.
Compiling seems to be another way of caching, if i'm not mistaken.

Edit : Sam beat me Smile
True the CI caching isn't very advanced but there are advanced cache libraries.

El Forum

[eluser]CodeIgniterNewbie[/eluser]
So, are those reasons enough to also include Smarty in a CI project?

El Forum

[eluser]CodeIgniterNewbie[/eluser]
Ugh. My last comment was for Grad Student, not for Lab Technician.

So, I am leaning against using Smarty. Is this a good idea?

El Forum

[eluser]Sam Dark[/eluser]
xwero, CI's native view caching is a toy copared to Smarty's.
Pages: 1 2