Sha256: f3196aeb675c74371a631dd9259f2e193997ee4d322869a4871b8c18ed46a0a6
Contents?: true
Size: 793 Bytes
Versions: 1
Compression:
Stored size: 793 Bytes
Contents
module Brochure class Template attr_reader :app, :path def initialize(app, path) @app = app @path = path end def template @template ||= Tilt.new(path, nil, :outvar => '@_out_buf') end def engine_extension @engine_extension ||= File.extname(path) end def format_extension @format_extension ||= begin ext = File.extname(File.basename(path, engine_extension)) ext.empty? ? ".html" : ext end end def content_type @content_type ||= begin type = Rack::Mime.mime_type(format_extension) type[/^text/] ? "#{type}; charset=utf-8" : type end end def render(env, locals = {}, &block) template.render(app.context_for(self, env), locals, &block) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
brochure-0.5.0 | lib/brochure/template.rb |