Skip to content

Instantly share code, notes, and snippets.

@djanowski
Created July 10, 2015 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djanowski/77b05564376970d08cc1 to your computer and use it in GitHub Desktop.
Save djanowski/77b05564376970d08cc1 to your computer and use it in GitHub Desktop.
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