Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I inject actual html from the model to the template?

In my admin, I have a text area where the user can input html:

<ul>
  <li>blah</li>
</ul>
<p>
  Stuffs
</p>

When I push the above to my template and I view the source of the page, I get:

&lt;ul&gt;
  &lt;li&gt;blah&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  Stuffs
&lt;/p&gt;

What should I do with my output so that I see actual html in the page source?

like image 777
Thierry Lam Avatar asked Oct 09 '09 16:10

Thierry Lam


People also ask

How do I get HTML templates?

You can use the <template> tag if you have some HTML code you want to use over and over again, but not until you ask for it. To do this without the <template> tag, you have to create the HTML code with JavaScript to prevent the browser from rendering the code.


1 Answers

you need the 'safe' filter. As it's autoescaped.

{{ my_html|safe }}
like image 112
Nixarn Avatar answered Oct 31 '22 18:10

Nixarn