Created
July 10, 2015 13:03
-
-
Save djanowski/77b05564376970d08cc1 to your computer and use it in GitHub Desktop.
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
module Syro::Render | |
HTML = "text/html; charset=utf-8".freeze | |
TEMPLATES = {} | |
def page(path) | |
template(path, "layout") | |
end | |
def template(path, layout = nil) | |
TEMPLATES[[path, layout]] ||= begin | |
dir = File.join("views", self.class.prefix) | |
Page.new("#{dir}/#{path}.mote", (template(layout) if layout)) | |
end | |
end | |
def render(page) | |
res.headers[Rack::CONTENT_TYPE] = HTML | |
res.write(page) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment