Question

I am using twig in a dynamic way to generate template and I want to show a twig variable that is stored in database (the value is {{entity.id}}).

    {%- for parameter in reportParameters%}
       {{ parameter.name }} : {{ parameter.value }}
     {%- endfor %}

The parameter.value should show 1 (the id of the current entity), but it shows {{entity.id}}

Is there equivalent to eval in php for twig?

Was it helpful?

Solution

Some kind folk are working on this extension at the minute but I don't think it's been pulled into the master branch yet. It looks as though we're going to have an "EvaluateString" twig function soon. Here it is:

https://github.com/fabpot/Twig-extensions/pull/53

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top