Skip to content

Instantly share code, notes, and snippets.

@technicalpickles
Created September 14, 2009 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save technicalpickles/186501 to your computer and use it in GitHub Desktop.
Save technicalpickles/186501 to your computer and use it in GitHub Desktop.
Rails TemplateHandler for using plain ol ruby
{
:a => 2,
# NOTE for partials, you need to include the format
# otherwise, it'll fail to find byows/_byow.erb even if byows/_byow.html.erb exists
:b => render(:partial => 'example.html')
}.to_json
class RbTemplate < ActionView::TemplateHandler
include ActionView::TemplateHandlers::Compilable if defined?(ActionView::TemplateHandlers::Compilable)
def compile(template)
template.source
end
end
ActionView::Template.register_template_handler(:rb, RbTemplate)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment