Class Tilt::HamlTemplate
In: lib/sinatra/tilt.rb
Parent: Template
Template BuilderTemplate LessTemplate RDiscountTemplate LiquidTemplate RDocTemplate MustacheTemplate StringTemplate RedClothTemplate HamlTemplate ERBTemplate CoffeeTemplate SassTemplate ErubisTemplate Cache lib/sinatra/tilt.rb CompileSite Tilt dot/m_2_0.png

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

Methods

Public Instance methods

[Source]

     # File lib/sinatra/tilt.rb, line 450
450:     def evaluate(scope, locals, &block)
451:       if @engine.respond_to?(:precompiled_method_return_value, true)
452:         super
453:       else
454:         @engine.render(scope, locals, &block)
455:       end
456:     end

[Source]

     # File lib/sinatra/tilt.rb, line 440
440:     def initialize_engine
441:       return if defined? ::Haml::Engine
442:       require_template_library 'haml'
443:     end

[Source]

     # File lib/sinatra/tilt.rb, line 481
481:     def precompiled_postamble(locals)
482:       @engine.instance_eval do
483:         "\#{precompiled_method_return_value}\nensure\n@haml_buffer = @haml_buffer.upper\nend\n"
484:       end
485:     end

[Source]

     # File lib/sinatra/tilt.rb, line 465
465:     def precompiled_preamble(locals)
466:       local_assigns = super
467:       @engine.instance_eval do
468:         "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"
469:       end
470:     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/sinatra/tilt.rb, line 461
461:     def precompiled_template(locals)
462:       @engine.precompiled
463:     end

[Source]

     # File lib/sinatra/tilt.rb, line 445
445:     def prepare
446:       options = @options.merge(:filename => eval_file, :line => line)
447:       @engine = ::Haml::Engine.new(data, options)
448:     end

[Validate]