I am using twig as templating engine and i am facing issue while displaying HTML data.
I searched on SO and got following solution
{% autoescape true %} {{ detailArticle.artdesc|raw}} {% endautoescape %}
This expression is working on my localhost but giving problem on cPanel the is Live server.
It is not rendering the output. It is displayed as
<span style="font-size: 12pt; font-family: 'Times New Roman', serif">.. so on
Twig version used is
"twig/twig": "~1.16",
Please suggest
You're using autoescape
, which buffers the contents of that block, and then filters it (escaping HTML entities and so on). If you want to print out a variable that contains markup, use either this:
{{ detailArticle.artdesc|raw }}
Printing the value as a raw string (no escaping at all), or:
{% autoescape false %}
{{ detailArticle.artdesc }}
{% endautoescape %}
Which is the same as using raw
on all variables you're using inside that block
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With