views:

125

answers:

4

I'm currently using the Smarty templating system for our production site, but am curious how much of a performance hit I'm taking by using this templating engine. Are there faster alternatives? Is there a way to code so I may not have to use such a templating system? Thank you!

+1  A: 

The obvious answer - just use PHP. Many argue that it IS a templating language, although I prefer to use Smarty.

Smarty forces PHP developers to separate business logic, database calls, etc from the presentation. However, a disciplined PHP developer can use PHP as a templating language and keep the presentation separate.

jonstjohn
+5  A: 

You don't need an external templating engine to separate code from presentation, you just need logic for that. PHP itself is perfectly fine as a template engine -- just don't mix PHP code and HTML. Template engines are just easier to learn for a non programmer web designer.

kemp
+1  A: 

Also you can use XSL transformations to separate logic from presentation. XSLT-transformer receives XML tree and generates HTML output, using XSLT transformations to produce presentation.

But XSLT is quite difficult for studying and demands knowledge of XML and XPath. I have been using Smarty in my recent projects, but my current project is build on XSLT templates, so I had to learn XSLT. It seems more complicated to me, that Smarty and its ancestor FastTemplate. However, XSLT is another way to separate logic from presenatation.

Advantage of XML & XSLT is that these technologies are used with different languages, not only with PHP.

Besides there is one more template engine - PHP template engine. It is default template engine for Drupal CMS. I'm not Drupal expert, so I can say nothing about it. However it uses PHP syntax, so it is quite simple to learn.

You can read about XSLT here.

I hope my answer will be useful for you.

Alex
A: 

You can try Psttt! templating engine for php

full source code here http://github.com/givanz/psttt

codeassembly