Skip to content

Instantly share code, notes, and snippets.

@ircmaxell
Last active December 11, 2015 23:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ircmaxell/beb8aa744a016837864b to your computer and use it in GitHub Desktop.
Save ircmaxell/beb8aa744a016837864b to your computer and use it in GitHub Desktop.
/**
* retrieves rendered field template
* @param string $templateName
* @param function $prepareTemplateDataFunction a method that accepts 1 param the template data array object and returns it modified before passing it to the template for rendering
* @return string
*/
public function render($templateName, callable $prepareTemplateDataFunction = null){
$template = $this->getTemplate($templateName);
$templateData = $this->getTemplateData();
if($prepareTemplateDataFunction){
$templateData = $prepareTemplateDataFunction($templateData);
}
$template->templateData = $templateData;
return $template->fetch();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment