Skip to content

Instantly share code, notes, and snippets.

@defunkt
Created May 27, 2010 01:41
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save defunkt/415329 to your computer and use it in GitHub Desktop.
Save defunkt/415329 to your computer and use it in GitHub Desktop.
Dirt cheap layouts with Mustache.
require 'mustache'
class Layout < Mustache
self.template = "Header
{{{yield}}}
Footer"
end
class Index < Mustache
self.template = "The Index."
end
class Profile < Mustache
self.template = "The Profile."
end
def render(klass)
view = Layout.new
view[:yield] = klass.render
view.render
end
puts "Index:"
puts render(Index)
puts
puts "Profile:"
puts render(Profile)
@jchris
Copy link

jchris commented May 27, 2010

Fascinating. I would love to see this running inside the Ruby CouchDB query server, and the things people could do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment