I'm trying to convert a description, which is a string from my database, into HTML. I'm getting the description with {{ projet.description }}
, but it seems that in JavaScript, "description" causes a bug in my script... So I create a div with my description on it, make it invisible, and get it with innerHTML
.
Twig code
<div id="desc">{{ projet.description }}</div>
<div>
<script type="text/javascript">
var desc = document.getElementById("desc").innerHTML|e('js')|raw;
document.write(desc);
</script>
</div>
CSS
#descr {
display:none;
}
But now, document.write()
still returns a string like "<p><em>POKEMON</em></p>
". However, I want it in HTML.