Sha256: dfaf4fdbf91b6895016a21161bc238707634f7c03475560a8c3c459f1b6d6ed3
Contents?: true
Size: 1.04 KB
Versions: 2
Compression:
Stored size: 1.04 KB
Contents
require 'tilt/erb' module Angelo module Tilt module ERB DEFAULT_LAYOUT = 'layout.%s' DEFAULT_TYPE = :html LAYOUTS_DIR = 'layouts' ACCEPT_ALL = '*/*' def erb view, opts = {} type = opts.delete(:type) || template_type content_type type if view.is_a? Symbol view = :"#{view}.#{type}" end layout = case opts[:layout] when false false when Symbol :"#{LAYOUTS_DIR}/#{layout}.#{type}" else :"#{DEFAULT_LAYOUT % type}" end _erb view, layout: layout, locals: opts[:locals] end def template_type accept = request.headers[ACCEPT_REQUEST_HEADER_KEY] mt = if accept.nil? or accept == ACCEPT_ALL MIME::Types[headers[CONTENT_TYPE_HEADER_KEY]] else MIME::Types[request.headers[ACCEPT_REQUEST_HEADER_KEY]] end mt.first.extensions.first.to_sym rescue DEFAULT_TYPE end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
angelo-0.5.1 | lib/angelo/tilt/erb.rb |
angelo-0.5.0 | lib/angelo/tilt/erb.rb |