Sha256: 7cc28d0905c26276d45a4725817d644b07a489a4ac36bb854c96acee5949063f
Contents?: true
Size: 735 Bytes
Versions: 1
Compression:
Stored size: 735 Bytes
Contents
class Servel::HamlContext include ActiveSupport::NumberHelper ENGINE_OPTIONS = { remove_whitespace: true, escape_html: true, ugly: true } def initialize() @build_path = Pathname.new(__FILE__).dirname.realpath + 'templates' @haml_engine_cache = {} end def render(template, locals = {}) haml_engine(template).render(self, locals) end def partial(name, locals = {}) render("_#{name}.haml", locals) end def include(path) (@build_path + path).read end def haml_engine(path) unless @haml_engine_cache.key?(path) @haml_engine_cache[path] = Haml::Engine.new(include(path), ENGINE_OPTIONS.merge(filename: path)) end @haml_engine_cache[path] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
servel-0.9.0 | lib/servel/haml_context.rb |