Score:0

Output of Twig truncated field value sanitezes punctuation characters

cn flag

I output the text of a field in a twig template truncated to 160 characters like:

{% set text = content.field_text.0|render|striptags %}
{{ text|length > 160 ? text|slice(0, 160) ~ '...' : text }}

But when a user enters quotations marks, ampersand and other punctuation characters, they are rendered as

" or &. 

Is there a way to "unsantize" these again, so they are put out the right way as " or &?

Thank you very much in advance!

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.