Skip to content

Instantly share code, notes, and snippets.

@defunkt
Created March 19, 2011 19:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save defunkt/877708 to your computer and use it in GitHub Desktop.
Save defunkt/877708 to your computer and use it in GitHub Desktop.
Handing Mustache normal Ruby objects
class Highlighter
def ruby(text)
"<pre class='ruby'>#{text}</pre>"
end
def python(text)
"<pre class='python'>#{text}</pre>"
end
end
tpl = <<-END
{{#hl.ruby}}
def alert(thing)
puts thing
end
{{/hl.ruby}}
END
puts Mustache.render(tpl, :hl => Highlighter.new)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment