Created
July 2, 2011 10:09
-
-
Save developish/1059914 to your computer and use it in GitHub Desktop.
I thought the problem was Rails safe buffers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assuming that :something is trusted | |
Mustache.render("<h1>template</h1> {{ something }}", {:something => "<h2>Testing</h2>" }) | |
# => <h1>template</h1> <h2>Testing</h2> | |
# 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