title: In Smarty3, call a template function defined by the {function} tag from within a plugin function
body: <p>Smarty <a href="http://www.smarty.net/docs/en/language.function.call.tpl" rel="nofollow"><code>{call}</code></a> built-in function is able to call a template function defined by the {function} tag. Now, I need to call a template function but <strong>inside a plugin</strong> function because I only know the function name inside the plugin. </p>
  
  <p><strong>Plugin function:</strong></p>
  
  <pre><code>&lt;?php
  
  $smarty-&gt;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-&gt;getVariables();
  
      // How to call the Smarty template function with the given $args?
      // $html = $template-&gt;smarty-&gt;???($args); 
  
      //return $html;
  }
  </code></pre>
  
  <p><strong>Template:</strong></p>
  
  <pre><code>&lt;form action="submit.php" method="post"&gt;
      {form_label}
      ....
  &lt;/form&gt;
  </code></pre>
  
  <p><em>This is an effort to support <a href="http://symfony.com/doc/current/book/forms.html" rel="nofollow">Symfony2 Forms</a> in <a href="https://github.com/noiselabs/SmartyBundle" rel="nofollow">SmartyBundle</a>. 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.</em></p>