Sha256: 3215ba6b95024a2edecf8d6cbf1afc7a2e4070f0264ec230661728fda4ce127a
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
require 'malt/engines/abstract' module Malt::Engine # Haml # class Haml < Abstract default :haml # def render(params, &yld) format = params[:format] case format when :html, nil render_html(params, &yld) else super(params, &yld) end end # def render_html(params, &yld) text = params[:text] file = params[:file] data = params[:data] engine = intermediate(params) case data when Binding html = engine.render(make_object(data), &yld) when Hash html = engine.render(Object.new, data, &yld) else if data.respond_to?(:to_hash) data = data.to_hash html = engine.render(Object.new, data, &yld) else html = engine.render(data || Object.new, &yld) end end html end # #def compile(text, file) # intermediate # ?? #end # def intermediate(params) text = params[:text] file = params[:file] ::Haml::Engine.new(text, :filename=>file) end private # Load Haml library if not already loaded. def initialize_engine return if defined? ::Haml::Engine require_library 'haml' end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
malt-0.1.1 | lib/malt/engines/haml.rb |