Class: Tilt::HamlTemplate
Overview
Haml template implementation. See: haml.hamptoncatlin.com/
Instance Attribute Summary
Attributes inherited from Template
Instance Method Summary collapse
- #evaluate(scope, locals, &block) ⇒ Object
- #precompiled_postamble(locals) ⇒ Object
- #precompiled_preamble(locals) ⇒ Object
-
#precompiled_template(locals) ⇒ Object
Precompiled Haml source.
- #prepare ⇒ Object
Methods inherited from Template
#basename, default_mime_type, default_mime_type=, #eval_file, #initialize, metadata, #metadata, #name, #render
Constructor Details
This class inherits a constructor from Tilt::Template
Instance Method Details
#evaluate(scope, locals, &block) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/tilt/haml.rb', line 15 def evaluate(scope, locals, &block) raise ArgumentError, 'invalid scope: must not be frozen' if scope.frozen? if @engine.respond_to?(:precompiled_method_return_value, true) super else @engine.render(scope, locals, &block) end end |
#precompiled_postamble(locals) ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/tilt/haml.rb', line 47 def precompiled_postamble(locals) @engine.instance_eval do <<-RUBY #{precompiled_method_return_value} ensure @haml_buffer = @haml_buffer.upper if @haml_buffer end RUBY end end |
#precompiled_preamble(locals) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/tilt/haml.rb', line 32 def precompiled_preamble(locals) local_assigns = super @engine.instance_eval do <<-RUBY begin extend Haml::Helpers _hamlout = @haml_buffer = Haml::Buffer.new(@haml_buffer, #{.inspect}) _erbout = _hamlout.buffer __in_erb_template = true _haml_locals = locals #{local_assigns} RUBY end end |
#precompiled_template(locals) ⇒ Object
Precompiled Haml source. Taken from the precompiled_with_ambles method in Haml::Precompiler: github.com/nex3/haml/blob/master/lib/haml/precompiler.rb#L111-126
28 29 30 |
# File 'lib/tilt/haml.rb', line 28 def precompiled_template(locals) @engine.precompiled end |
#prepare ⇒ Object
10 11 12 13 |
# File 'lib/tilt/haml.rb', line 10 def prepare = @options.merge(:filename => eval_file, :line => line) @engine = ::Haml::Engine.new(data, ) end |