I have the folowing long variable in Twig to read the src
attribute of an image in RSS feed:
<img src="{{item.get_item_tags("http://www.w3.org/2005/Atom","link")[0]['child']['http://search.yahoo.com/mrss/']['content'][0]['child']['http://search.yahoo.com/mrss/']['thumbnail'][0]['child']['http://www.w3.org/2005/Atom']['img'][0]['attribs']['']['src']}}"/>
I want to make the code more cleaner and readable, so initially, I defined two variables to act as parameter of get_item_tags()
and the other as a path for the array:
{% set param1 = 'http://www.w3.org/2005/Atom' %}
{% set arrayPath = '[0]['child']['http://search.yahoo.com/mrss/']['content'][0]['child']['http://search.yahoo.com/mrss/']['thumbnail'][0]['child']['http://www.w3.org/2005/Atom']['img'][0]['attribs']['']['src']' %}
What I want to get, but it generate error, is:
<img src="{{item.get_item_tags({{param1}}, "link"){{arrayPath}}}}" />
I don't use symfony and Twig version is 1.16.0