1

I´m trying to insert dynamic links in a twig template, but when I render the page it shows the raw HTML.

I send the variables as an array ('fact' => ['tag' => '<a href="loremipsum">tag</a>']) for example) and then in the twig {{ fact.tag }}, but as mentioned it returns the raw tag.

Am I doing something wrong?

2
  • 5
    try {{ fact.tag|raw }} Commented Mar 16, 2017 at 14:44
  • 1
    or ('fact' => ['tag' => new \Twig_Markup('<a href="loremipsum">tag</a>','UTF-8')]) Commented Mar 16, 2017 at 14:57

1 Answer 1

4

Here is a Twigfiddle to show that {{ fact.tag|raw }} is the correct answer. It shows both with and without the raw filter:

https://twigfiddle.com/d4hc55

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.