Skip to content

Instantly share code, notes, and snippets.

@defunkt
Forked from aumgn/gist:864853
Created March 19, 2011 18:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save defunkt/877705 to your computer and use it in GitHub Desktop.
Save defunkt/877705 to your computer and use it in GitHub Desktop.
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