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?

Luwe
  • 3,026
  • 1
  • 20
  • 21
xquezme
  • 61
  • 1
  • Somewhere in the process these html characters are escaped. Find where that happend and make it not happen any more. – GolezTrol Sep 20 '11 at 09:33

2 Answers2

9

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

<div>{{{param}}}</div>
Tron5000
  • 844
  • 11
  • 24
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'
});
chawkinsuf
  • 1,381
  • 1
  • 12
  • 13