Skip to content

Instantly share code, notes, and snippets.

@developish
Created July 2, 2011 10:09
Show Gist options
  • Save developish/1059914 to your computer and use it in GitHub Desktop.
Save developish/1059914 to your computer and use it in GitHub Desktop.
I thought the problem was Rails safe buffers
# Assuming that :something is trusted
Mustache.render("<h1>template</h1> {{ something }}", {:something => "<h2>Testing</h2>" })
# => <h1>template</h1> &lt;h2&gt;Testing&lt;/h2&gt;
# Desired out is "<h1>template</h1> <h2>Testing</h2>"
# Solution, use the triple mustache - {{{ }}} - for content that shouldn't be escapes
Mustache.render("<h1>template</h1> {{{ something }}}", {:something => "<h2>Testing</h2>" })
# => <h1>template</h1> <h2>Testing</h2>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment