Class Tilt::HamlTemplate
In: lib/tilt.rb
Parent: Template

Haml template implementation. See: haml.hamptoncatlin.com/

Methods

Public Instance methods

[Source]

     # File lib/tilt.rb, line 491
491:     def evaluate(scope, locals, &block)
492:       if @engine.respond_to?(:precompiled_method_return_value, true)
493:         super
494:       else
495:         @engine.render(scope, locals, &block)
496:       end
497:     end

[Source]

     # File lib/tilt.rb, line 481
481:     def initialize_engine
482:       return if defined? ::Haml::Engine
483:       require_template_library 'haml'
484:     end

[Source]

     # File lib/tilt.rb, line 522
522:     def precompiled_postamble(locals)
523:       @engine.instance_eval do
524:         "\#{precompiled_method_return_value}\nensure\n@haml_buffer = @haml_buffer.upper\nend\n"
525:       end
526:     end

[Source]

     # File lib/tilt.rb, line 506
506:     def precompiled_preamble(locals)
507:       local_assigns = super
508:       @engine.instance_eval do
509:         "begin\nextend Haml::Helpers\n_hamlout = @haml_buffer = Haml::Buffer.new(@haml_buffer, \#{options_for_buffer.inspect})\n_erbout = _hamlout.buffer\n__in_erb_template = true\n_haml_locals = locals\n\#{local_assigns}\n"
510:       end
511:     end

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

[Source]

     # File lib/tilt.rb, line 502
502:     def precompiled_template(locals)
503:       @engine.precompiled
504:     end

[Source]

     # File lib/tilt.rb, line 486
486:     def prepare
487:       options = @options.merge(:filename => eval_file, :line => line)
488:       @engine = ::Haml::Engine.new(data, options)
489:     end

[Validate]