Developer
Developer

Reputation: 2895

Rendering Twig template in PHP template

I am rendering a PHP template with Symfony 2, the template code I have:

phptemplate.html.php:

...
<?php echo $view->render('MyBundle:Def:info.html.twig', array('m' => $m)) ?>
...

MyBundle:Def:info.html.twig:

abc
{{ url('form_individual') }}
{{ m.test }}
abc

Output display result:

abc
{{ url('form_individual') }}
{{ m.test }}
abc

Variables are not rendered but instead are displayed as text, why?

Upvotes: 1

Views: 702

Answers (1)

NHG
NHG

Reputation: 5877

PhpEngine, which in fact you used, doesn't support twig templates. So, yourtwigtemplate is (probably) parsed as a plain text.

PhpEngine supports method Source code and here base doc for supports where is: Returns true if this class is able to render the given template..

Why you didn't rewrite your MyBundle:Def:info.html.twig template to php? Or parent one to twig?

Upvotes: 1

Related Questions