ftlabs / fruitmachine

View rendering engine
MIT License
247 stars 18 forks source link

How to handle if json response from server contains html tags? #49

Closed sackIndian closed 11 years ago

sackIndian commented 11 years ago

Hi,

I am using hogan with Fruitmachine.js,

Sample senario, Here i define modules as

var Masthead = fruitmachine.define({ name: 'masthead', template: templateMasthead, });

var templateMasthead = Hogan.compile("{{title}}");

Now i provide json data for fruitmachine as

var layout = { module: 'masthead', model: { title: '

Article viewer

Main name

' } }; var view = fruitmachine(layout); view .render() .inject(document.getElementById('app'))

when i inject view to div, it displays html tags along with string values?

How to handle these kind of situations? (json response from server contains html tags)

Thank you,

wilsonpage commented 11 years ago

It looks to me as though you are looking for the triple mustache. This will make sure that Mustache/Hogan will not escape html.

var templateMasthead = Hogan.compile("{{{title}}}");