I need to render data with unknown type with filters that specific on each data type:
the rendered structures looks like:
array(
"value" => "value-to-render",
"filter" => "filter-to-apply",
)
{% for item in items %}
{{ item.value|item.filter|raw}}
{% endfor %}
So My Question is: How can I get twig to use item.filter as a filter on the value?
You have to write your filter, which will call filters by passing name to it.
How to initially write you Extension you can read here.
Assuming that you have created you extension, you have define your custom function, (e.g.,
customFilter).Then, you have to define this function
After this manipulations you’ll be able to call in Twig:
Or, if you’ve defined your filter as filter (not as function):