Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

MustacheHandler for Rails

View mustache_hander.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14
class MustacheHandler < ActionView::Template::Handler
include ActionView::Template::Handlers::Compilable
 
# @return [String] its evaled in the context of the action view
# hence the hack below
#
# @param [ActionView::Template]
def compile(template)
mustache_class = ::Mustache
"#{mustache_class}.render('#{template.source}', assigns.merge(local_assigns)).html_safe"
end
end
 
ActionView::Template.register_template_handler(:mustache, MustacheHandler)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.