Reputation: 181
I have the code below and I need to pass an html element (anchor) as shown. I have tried using filters like raw and escape but it always prints out the html element as regular text. I also tried setting a new variable that contains the same string text and passed that to testLink and then applied filters to it, but same result. Any ideas how to tackle this problem?
{% include 'example.html.twig' with {'testLink': 'Hurry, <a href="#">Click me NOW</a>'} %}
Upvotes: 0
Views: 188
Reputation: 5881
You cannot handle your problem in the template that is including the example.html.twig
template as autoescaping will step in when the passed value is displayed in the included template. Instead, you will have to use the raw
filter in example.html.twig
(be careful with that solution though as the template is probably used in other places too which might not be safe).
Upvotes: 2