문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top