» Metadata | » Status | |
---|---|---|
|
|
|
» Description | ||
HTML_Template_SavantOverviewSavant is a powerful but lightweight template system for PHP. It is primarily for PHP developers, not HTML designers, although anyone with any amount of PHP knowledge can use it. Savant uses PHP itself as its template language so you don't need to learn a new markup system (c.f. comments and explanation from Harry Fuecks and Brian Lozier). Savant leverages the existing strengths of PHP to create the most effective template system possible. Savant is not Xipe-lite, becuase Savant is not a compiling template engine. All compiling template engines have an inherent security risk of requiring a writable directory, as well as making re-distributable templates very difficult to maintain. Savant does not carry this risk or diffuculty. Unlike other non-compiling template engines, Savant has no need for complex template parsing logic, and is therefore lightweight, faster than any existing template engine, and has the capability to generate binary files as well as text files. Savant could be used to generate customized images, for instance. No HTML_Template_* engine has this kind of power. In fact, a better top-level category for Savant would be just "Template" (for "Template_Savant"). Savant has an object-oriented system of template plugins and output filters, so it sports almost all of the power and flexibility of Smarty with almost none of the overhead. ProvidesSavant...
Savant does not compile templates. Savant templates are written in plain, natural PHP with regular <?php ... ?> tags, so no compilation or evaluation is necessary; it just includes the template code within the Savant object context at display() or fetch() time. Savant does not have a built-in caching mechanism. If you want to cache output, I figure you probably want your application to provide that, not the template subsystem. Use Cache or Cache_Lite if you want to cache Savant output. ExampleLogic ScriptHere is an example use of Savant. The following business logic script populates and displays a Savant template (shown below).
In the above example, we use an array to assign a number of template variable tokens at once; it is just as easy to assign an object instead of an array, and the object properties will be assigned to the template. Template ScriptHere is the Savant template script, called example.tpl.php. Note how we use the alternative syntax for control structures here; it's not required, but it can be easier to read in many cases.
Note that the template language is natural PHP without any special markup or "helpful" shortcuts. Because the template is in natural PHP, any errors in processing the template are immediately transparent, as they are reported on the actual source template script and not an intermediary cached or compiled script. Plugins and FiltersYou can use the standard Savant plugins within your Savant template, and you can write your own. Savant plugins are comparable to Smarty plugins. Please see http://phpsavant.com/index.php?page=SavantPlugins for more information. You can use the standard Savant output filters on the displayed or fetched template output, and you can write your own. Please see http://phpsavant.com/index.php?page=SavantFilters for more information. CachingHere is a simple example of how to cache output with Savant and Cache_Lite.
Other PackagesWhy does PEAR need another template system? Why not contribute to another package? All of the PEAR template packages do some form of template compiling and evaluation, and they all (with one exception, sort of) use a custom template language. Savant does neither: no compiling, and no special markup. IT, PHPLIB, SigmaThese template engines are not directly comparable to Savant for various reasons.
Flexy, XipeThese template engines are comparable to Savant because of the power and flexibility they provide.
Again, Savant is already in PHP, so no compilation is necessary. Although Xipe supports pre- and post-filters, they apply to the compiled PHP code, not the generated output. Of these template systems in PEAR, the one that is brought up most often form comparison is Xipe. This came up on the Savant website; the question is verbatim, but I have updated and edited the answer for use in this proposal (it is substantially the same answer as on the website). Question:
My answer:
Other Reasons For SavantSavant templates are easy for new and experienced PHP developers to comprehend, modify, and debug, becuase templates are already in PHP (no need to learn a new template markup) Savant templates, because they are already in PHP, can be documented with phpDocumentor. Savant templates can be used for anything: HTML, RSS, XML, PDF, RTF, any kind of binary or text file. Savant does not attempt to impose on your coding style any more than minimally necessary, and at the same time it tries to operate as intelligently and transparently as possible. For example, if you like assigning individual scalar elements, assign() works for you; if you prefer to assign by associative array, assign() works for you too; finally, if object properties are your thing, assign() still works for you. Savant is perfect for distributed applications. Among other things, the end user does not have to worry about compile-directory or cache-directory permissions, because Savant does not compile templates. Because of the path management utilities in Savant, developers can make their applications theme-aware with little effort. Savant is STABLE at version 1.5 and in production at many high-traffic sites, although the package file linked in this proposal is 0.0.x-devel due to refactoring based on proposal commentary. Harry Fuecks notes:
And finally, in reference to a recent PEAR-QA thread, it appears that Wolfram Kriesing is orphaning Xipe. Because Flexy is the natural successor of Xipe, Xipe may eventually be deprecated. Possible Enhancements
Casino Vavada welcomes new players with several exciting bonuses. Get 100 free spins as a gift to start your journey in the world of slots, and also enjoy a 100% bonus on your first deposit. |
||
» Dependencies | » Links | |
|
||
» Timeline | » Changelog | |
|
|