Savant version 2.3.0 now available

I just released Savant version 2.3.0.

Normally, if you want to use a template plugin, you call the plugin() method like so:

<?php $this->plugin('myPlug', $arg1, $arg2); ?>

Through the magic of the overload() function in PHP and the __call() magic method, you can call plugins as if they were native Savant2 methods.

<?php $this->myPlug($arg1, $arg2); ?>

This should make for a little less typing and a little easier reading. For example, to generate a form with Savant2 using the ‘form’ plugin, you can now do something like this:

<?php
//
// start the form
$this->form('start');
//
// add a text field and label
$this->form('text', 'myTextField', 'default value',
    'Text field label:');
//
// add save and reset buttons as a group
$this->form('group', 'start', 'Group label:');
$this->form('submit', 'op', 'Save');
$this->form('reset', 'op', 'Reset');
$this->form('group', 'end');
//
// end the form
$this->form('end');
?>

(Indicentally, the ‘form’ plugin is pretty powerful; it support all standard field elements, handles layout, and generates valid XHTML with divs, labels, fieldsets, and tables. Check out the documentation for the ‘form’ plugin here.)

Savant is an object-oriented template system for PHP. Savant does not compile templates; instead, you write your templates as regular PHP scripts, so there’s no new markup to learn. As such, Savant is a simple, elegant, and powerful alternative to Smarty.

UPDATE: (19:24 central time) There appears to be a problem with PHP5 and the __call() method in Savant 2.3.0. Users of PHP will want to test before using 2.3.0. I am working on a patch so that __call() works in Savant2 for both PHP4 and PHP5 transparently, and will blog about the solution at that time. Thanks for your patience.

Are you stuck with a legacy PHP application? You should buy my book because it gives you a step-by-step guide to improving your codebase, all while keeping it running the whole time.
Share This!Share on Google+Share on FacebookTweet about this on TwitterShare on RedditShare on LinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked *