Skip to content

Instantly share code, notes, and snippets.

@eric
Created January 25, 2011 20:58
Show Gist options
  • Save eric/795646 to your computer and use it in GitHub Desktop.
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
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