Created
January 25, 2011 20:58
-
-
Save eric/795646 to your computer and use it in GitHub Desktop.
Playing around with a possible .jsbuilder template type for outputting json in sinatra
This file contains 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
class JsBuilderTemplate < Template | |
def precompiled_preamble(locals) | |
[ super, "begin" ].join("\n") | |
end | |
def precompiled_postamble(locals) | |
"end.to_json" | |
end | |
def precompiled_template(locals) | |
data.to_str | |
end | |
end | |
Tilt.register 'jsbuilder', JsBuilderTemplate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment