Top "Twig" questions

Twig is a modern, fast, flexible, and secure templating engine for PHP.

How to display string that contains HTML in twig template?

How can I display a string that contains HTML tags in twig template? My PHP variable contains this html and …

php html symfony twig
Add more than one parameter in Twig path

How to add more than one parameter in Twig path? Say you have this route : article_show: pattern: /article/{slug} …

symfony twig
Twig ternary operator, Shorthand if-then-else

Does Twig support ternary (shorthand if-else) operator? I need some conditional logic like: {%if ability.id in company_abilities %} <…

php twig conditional-operator
Find substring in the string in TWIG

I want to find substring of the string or check if there is no such substring using Twig. On the …

php twig substring comparison-operators
Accessing session from TWIG template

I've searched a lot on the net how to access the global $_SESSION array from TWIG template and found this: {{…

php session symfony twig
Setting element of array from Twig

How can I set member of an already existing array from Twig? I tried doing it next way: {% set arr[…

php twig
symfony 2 twig limit the length of the text and put three dots

How can I limit the length of the text, e.g., 50, and put three dots in the display? {% if myentity.…

symfony twig
The CSRF token is invalid. Please try to resubmit the form

I'm getting this error message every time I try to submit the form: The CSRF token is invalid. Please try …

php symfony twig
How to include CSS file in Symfony 2 and Twig?

I'm playing around with Symfony2, and I have problems including CSS and JS files in Twig template. I have a …

symfony twig
Call PHP function from Twig template

I have a function in my controller that returns array of entities so in my twig template I do this …

symfony twig symfony-2.3