Developers are able to modify the behavior and possibilities of Twig (the PHP templating engine by Fabien Potencier) in many ways, ranging from very easy to very tough. It all starts with simply registering your extension, but from then on you can choose to create your own filters, functions and tests. I will quickly review your options, and show some best practices. After discussing these basic modifications, we'll take a look at creating token parsers and thinking up custom node types, which will enable you to define your own tags (the things between {% %}
). I will demonstrate the inner workings of Twig: from the loader, to the lexer, to the parser, to your own token parser, to creating nodes, filtering nodes using a node visitor and finally to the compiler, which transforms all nodes to plain old PHP.
@matthiasnoback talking about "Diving deep into Twig" #SymfonyCon pic.twitter.com/YA9D1vBKlj
— Sebastian Grodzicki (@sebgrodzicki) December 12, 2013