I'm working with a legacy code that uses Smarty. For one of the Ajax requests I need to return HTML code of a sub-template. Hence, I would like to pass a variable to the sub-template and store the processed template as string, so it can be passed back to Ajax callback.
I have no idea how to do that. Smarty fetch()
seems to do something like that, but I'm unable to pass $myData
into the sub-template.
What I want is this:
$content = $smarty->get_template_as_string('results.tpl', $myData);
return $content;
The get_template_as_string()
method does not exist in Smarty, just serves as an example of what I need.