Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Mustache Object Implementation
class HighlighterHelper
def respond_to?(language)
Highlighter.highlight?(language)
end
def method_missing(language)
lambda { |text|
Highlighter.send(language, text)
}
end
end
myview = Mustache.new
def myview.hl
HighlighterHelper.new
end
tpl = <<-END
{{#hl.ruby}}
def alert(thing)
puts thing
end
{{/hl.ruby}}
END
puts myview.render(tpl)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment