HTML_Template_IT 1.2.0 beta released

Today we released the 1.2.0 beta of [b]HTML_Template_IT[/b].
As I mentioned, an option was added to HTML_Template_ITX::setCallbackFunction() to determine if call_user_func or call_user_func_array is used to call the callback function.
Example:[php]
function _numberFormatCallback($float, $decimals) {
return number_format($float, $decimals);
}

$tpl = new HTML_Template_ITX();
$tpl->setTemplate(‘callback:func_numberFormat(1.5, 2)’);
$tpl->setCallbackFunction(‘numberFormat’, ‘_numberFormatCallback’, ”, true);
$tpl->performCallback();
$tpl->show();
// prints “callback:1.50″
[/php]
Look a the line:
[php]
$tpl->setCallbackFunction(‘numberFormat’, ‘_numberFormatCallback’, ”, true);
[/php]
If last parameter ist true callback uses the expanded parameters, otherwise it uses the old way and passes only one array containing the parameters. The following example demonstrates the old behaviour:
[php]
// before 1.2 beta we have to do that:
function _numberFormatCallback($arr) {
return number_format($arr[0], $arr[1]);
}

$tpl = new HTML_Template_ITX();
$tpl->setTemplate(‘callback:func_numberFormat(1.5, 2)’);
$tpl->setCallbackFunction(‘numberFormat’, ‘_numberFormatCallback’, ”, false);
$tpl->performCallback();
$tpl->show();
// prints “callback:1.50″
[/php]
Also Pierre fixed the #7611 bug and I implemented the feature request #7651 to allow dots in placeholders and blocks. An example for the new blocks:


{a.new.placeholder}

Old placeholder pattern:

[0-9A-Za-z_-]+

New placeholder pattern:

[\.0-9A-Za-z_-]+

We also decided to deprecate $callbackobject parameter in HTML_Template_ITX::setCallbackFunction(). This paramter takes the name of a global defined object as a string and calls the callback method on that object. This can also be done using array($object, ‘callbackFunctionName’) and it’s more like a dirty hack than good code to use this parameter.

Furthermore API docs were cleaned a little bit.

Install the beta:

# pear -d preferred_state=beta install HTML_Template_IT

If no bugs will be found we will release [b]1.2.0 stable[/b] in about one or two weeks.

Leave a Reply