Class: Tilt::HamlTemplate

Inherits:
Template show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tilt-2.0.11/lib/tilt/haml.rb

Overview

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

Instance Attribute Summary

Attributes inherited from Template

#data, #file, #line, #options

Instance Method Summary collapse

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

Raises:

  • (ArgumentError)


22
23
24
25
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tilt-2.0.11/lib/tilt/haml.rb', line 22

def evaluate(scope, locals, &block)
  raise ArgumentError, 'invalid scope: must not be frozen' if scope.frozen?
  super
end

#precompiled_postamble(locals) ⇒ Object



74
75
76
77
78
79
80
81
82
83
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tilt-2.0.11/lib/tilt/haml.rb', line 74

def precompiled_postamble(locals)
  @engine.instance_eval do
    "        \#{precompiled_method_return_value}\n      ensure\n        @haml_buffer = @haml_buffer.upper if haml_buffer\n      end\n    RUBY\n  end\nend\n"

#precompiled_preamble(locals) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tilt-2.0.11/lib/tilt/haml.rb', line 59

def precompiled_preamble(locals)
  local_assigns = super
  @engine.instance_eval do
    "      begin\n        extend 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    RUBY\n  end\nend\n"

#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



55
56
57
58
59
60
61
62
63
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tilt-2.0.11/lib/tilt/haml.rb', line 55

def precompiled_template(locals)
  @engine.precompiled_with_ambles(
    [],
    after_preamble: "      __in_erb_template = true\n      _haml_locals = locals\n    RUBY\n  )\nend\n"

#prepareObject

Following definitions are for Haml <= 4 and deprecated.



37
38
39
40
41
42
43
44
45
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/tilt-2.0.11/lib/tilt/haml.rb', line 37

def prepare
  options = {}.update(@options).update(filename: eval_file, line: line)
  if options.include?(:outvar)
    options[:buffer] = options.delete(:outvar)
    options[:save_buffer] = true
  end
  @engine = ::Haml::TempleEngine.new(options)
  @engine.compile(data)
end