Jul 27

PHP Savant

Savant Template Engine: A good look at Savant, which is a template engine for PHP. Sort of.

Comparing Savant to Smarty is difficult. Yes they are both template engines, but Savant does not compile its templates. Nor does it have its own built in scripting syntax. It uses PHP.

Savant is a lot like using PHP amidst HTML, but it concentrates everything in an object. Of course, this doesn’t stop anyone from going “outside” the object and just writing PHP like crazy in their template, but it’s not designed to be sandboxed.

A lot of template engines are meant for non-programmers to write code, and I gather Savant isn’t like that — it’s just to let the programmer keep his presentation separate from his code. I’ll probably stick with Smarty, but Savant is nicely done.


Comments

by ,   July 27, 2005 12:45 PM  

it's not designed to be sandboxed

look here


by Paul M. Jones,   July 29, 2005 10:53 AM  

Hi Deane --

You said, "A lot of template engines are meant for non-programmers to write code, and I gather Savant isn’t like that — it’s just to let the programmer keep his presentation separate from his code. I’ll probably stick with Smarty, but Savant is nicely done."

First, thanks for looking at Savant, and thanks for the good words. :-)

I want to elaborate on the first poster's link to the Savant compiler documentation. The linked page points out that, by default, Savant does not compile templates. It expects templates to be in PHP; in this mode, Savant is mostly a developer's tool, not a designer's tool.

However, you can write any compiler you like and hook it into Savant. As long as the compiler returns a path to a compiled PHP script, you can base it on any kind of markup you like, such as simple variable substitution, or XSL/TAL, or domain-specific markups, or even a Smarty-like language.

This means that the compiling has been de-coupled from the variable-collection and processing aspects of the template system. If you like one kind of markup, you can write a compiler for it; if you like another, you can write a different compiler -- but you won't have to change the business-logic that assigns variables, picks templates, manages plugins, and so on.

Savant2 comes with a "basic" compiler as a proof-of-concept, but of course you can modify it (or write an entirely new one) to match your own tastes. So, not only is Savant fully capable of sandboxing, the sandbox can be of your own design for your own purposes. :-)

For more points and discussion on this matter, see RevJim's posts at:

http://revjim.net/item/10170/

http://revjim.net/item/10171/

Hope this helps to highlight some of the lesser-known capabilities of Savant in relation to Smarty; and thanks for the post. :-)

-- pmj



Add Comment


Want to advertise on this site? Contact FM.
Web Hosting Web hosting, dedicated servers and Web design services
Laser Toner Cartridges UK laser toner, toner cartridges, hp toner, lexmark toner, samsung toner, canon, toner, epson toner, oki toner, kyocera toner, xerox toner, remanufactured toner, compatible toner
Direct TV Deals Free 4 room direct tv deals. no equipment to buy. free fast professional direct tv installation. this is the best direct tv deal available anywhere.
SEO Article Learn from the experts with our SEO article.
rope light Shopping with birddog distributing, inc., gives you access to the lowest prices, the best customer service and the quickest delivery times possible.
Laptop AC Adapter We offer genuine factory direct replacement AC adapters.
Direct TV Best satellite TV deals.
Direct TV Deals Direct TV programming deals are varied and include packages containing from 50 channels up to over 250 channels.
8mm film to DVD Retain family memories with the only frame by frame digital restoration service in the United States for your 8mm film to DVD today
Rubber Stamp Shop for custom self-inking stamps, hand stamps, address stamps, label stamps, check endorsement stamps, check deposit stamps, date stamps, pre inks, pocket stamps, ink and much more!