twig template from string code example
Example 1: twig render string
$twig = new \Twig_Environment(new \Twig_Loader_String());
$rendered = $twig->render(
"Test string template: {{ result }}",
array("result" => "Success!")
);
Example 2: twig render string
$twig = clone $this->get('twig');
$twig->setLoader(new \Twig_Loader_String());
$rendered = $twig->render(
"Test string template: {{ result|humanize }}",
array("result" => "mega_success")
);