Smarty {call}
built-in function is able to call a template function defined by the {function} tag. Now, I need to call a template function but inside a plugin function because I only know the function name inside the plugin.
Plugin function:
<?php
$smarty->registerPlugin('function', 'form_label', 'renderFormLabel');
function renderFormLabel($form, \Smarty_Internal_Template $template) {
// find out which function to call based on the available ones
$function = lookupTemplateFunction($template);
$args = $form->getVariables();
// How to call the Smarty template function with the given $args?
// $html = $template->smarty->???($args);
//return $html;
}
Template:
<form action="submit.php" method="post">
{form_label}
....
</form>
This is an effort to support Symfony2 Forms in SmartyBundle. Each form fragment is represented by a Smarty function. To customize any part of how a form renders, the user just needs to override the appropriate function.