As you can see, he did not recommend using this function. Syntax tuning
Here's a quick and simple example to explain how to use custom separators in symfony:
service.yml
services: templating_lexer: public: true parent: templating.engine.twig class: Acme\YourBundle\Twig\TwigLexerEngine
TwigLexerEngine
namespace Acme\YourBundle\Twig; use Symfony\Bundle\TwigBundle\TwigEngine; class TwigLexerEngine extends TwigEngine { public function setTwigLexer($lexer) { $this->environment->setLexer($lexer); return $this; } }
Your controller
public function yourAction() { $lexer = new \Twig_Lexer($this->get('twig'), array( 'tag_comment' => array('{*', '*}'), 'tag_block' => array('{', '}'), 'tag_variable' => array('{$', '}'), )); $templating = $this->get('templating_lexer'); $templating->setTwigLexer($lexer); return $templating->renderResponse('YourBundle::template.html.twig'); }
a.aitboudad
source share