xquezme
xquezme

Reputation: 61

ICANHAZ.js render dom element instead of text

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?

Upvotes: 6

Views: 927

Answers (2)

chawkinsuf
chawkinsuf

Reputation: 1401

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'
});

Upvotes: 0

Tron5000
Tron5000

Reputation: 854

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

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

Upvotes: 9

Related Questions