Created
May 27, 2010 01:41
-
-
Save defunkt/415329 to your computer and use it in GitHub Desktop.
Dirt cheap layouts with Mustache.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fascinating. I would love to see this running inside the Ruby CouchDB query server, and the things people could do.