CodeIgniter Forums
Smarty in CI - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: Smarty in CI (/thread-7759.html)

Pages: 1 2


Smarty in CI - El Forum - 04-22-2008

[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?


Smarty in CI - El Forum - 04-22-2008

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


Smarty in CI - El Forum - 04-22-2008

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


Smarty in CI - El Forum - 04-22-2008

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


Smarty in CI - El Forum - 04-22-2008

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


Smarty in CI - El Forum - 04-22-2008

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


Smarty in CI - El Forum - 04-22-2008

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


Smarty in CI - El Forum - 04-22-2008

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


Smarty in CI - El Forum - 04-22-2008

[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?


Smarty in CI - El Forum - 04-22-2008

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