ICANHAZ.js render dom element instead of text
Asked Answered
W

2

6

Param:

'<div class="someclass">' + somecontent + '</div>' + somecontent2

Template:

<div>{{ param }}</div>

And in browser I have:

&lt;div class="someclass"&gt; somecontent &lt;/div&gt;somecontent2

How to isolate .someclass, that it render as a dom element, not text?

Wiretap answered 20/9, 2011 at 9:29 Comment(1)
Somewhere in the process these html characters are escaped. Find where that happend and make it not happen any more.Fowlkes
K
9

I think all Html elements are escaped by default. To return un-escaped Html use the triple mustache:

<div>{{{param}}}</div>
Karakul answered 13/12, 2011 at 21:48 Comment(1)
can i use mustache without any template? i am thinking to use in html without any template..Affectional
A
0

I would suggest using partial templates for this.

<script id="main" type="text/html">
<div>{{>partial}}</div>
</script>

<script id="partial" class="partial" type="text/html">
<div class="someclass">{{somecontent}}</div>{{somecontent2}}
</script>

Then just call the main template with your data as normal:

html = ich.main({
    somecontent: 'content',
    somecontent2: 'content2'
});
Aerugo answered 21/11, 2012 at 15:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.