I am currently writing several extensions in twig, but it is difficult for me to decide why some extension should be implemented as a tag or function.
The twig documentation contains the following 2 constructs and what they do:
{{ }} : used to print the result of evaluating an expression;{% %} : Used to execute statements.
I plan to implement something similar to symfony2's built-in controllers .
Why the function is implemented as:
{% render "AcmeDemoBundle:Demo:fancy" with { 'name': name, 'color': 'green' } %}
Since the function of the built-in controllers should return a fully visualized template for the requested controller, would the function be more suitable?
render("AcmeDemoBundle:Demo:fancy", { 'name': name, 'color': 'green' });
source share