/**
* Render a string
*
* A special option in the $locals array can be used to define the Twital adapter to use.
* The array key is `__twital-adapter`, and the value is an instance of `\Goetas\Twital\SourceAdapter`
*
* @param string $template The template content to render
* @param array $locals The variable to use in template
* @return null|string
*
* @throws \Twig_Error_Loader
* @throws \Twig_Error_Runtime
* @throws \Twig_Error_Syntax
*/
public function render($template, array $locals = array())
{
if (array_key_exists('__twital-adapter', $locals)) {
$this->stringLoader->addSourceAdapter('/.*/', $locals['__twital-adapter']);
}
// Render the file using the straight string.
$this->environment->setLoader($this->stringLoader);
return $this->environment->render($template, $locals);
}