Class: Tilt::HamlTemplate
Instance Attribute Summary
Attributes inherited from Template
#compiled_path, #data, #file, #line, #options
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
Following definitions are for Haml <= 4 and deprecated.
Methods inherited from Template
#basename, #compiled_method, 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
28 29 30 31 |
# File 'lib/tilt/haml.rb', line 28 def evaluate(scope, locals, &block) raise ArgumentError, 'invalid scope: must not be frozen' if scope.frozen? super end |
#precompiled_postamble(locals) ⇒ Object
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/tilt/haml.rb', line 81 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
66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/tilt/haml.rb', line 66 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
62 63 64 65 66 67 68 69 70 |
# File 'lib/tilt/haml.rb', line 62 def precompiled_template(locals) @engine.precompiled_with_ambles( [], after_preamble: <<-RUBY __in_erb_template = true _haml_locals = locals RUBY ) end |
#prepare ⇒ Object
Following definitions are for Haml <= 4 and deprecated.
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/tilt/haml.rb', line 43 def prepare @options[:filename] = eval_file @options[: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 |