Class: Haml::TempleEngine
- Inherits:
-
Temple::Engine
- Object
- Temple::Engine
- Haml::TempleEngine
- Defined in:
- lib/haml/template.rb,
lib/haml/temple_engine.rb
Instance Method Summary collapse
-
#compile(template)
-
#precompiled ⇒ String
The source code that is evaluated to produce the Haml document.
-
#precompiled_method_return_value_with_haml_xss
(also: #precompiled_method_return_value)
-
#precompiled_method_return_value_without_haml_xss
-
#precompiled_with_ambles(local_names, after_preamble: '') ⇒ String
The source code that is evaluated to produce the Haml document.
-
#precompiled_with_return_value
Instance Method Details
#compile(template)
39 40 41 42 |
# File 'lib/haml/temple_engine.rb', line 39
def compile(template)
initialize_encoding(template, options[:encoding])
@precompiled = call(template)
end
|
#precompiled ⇒ String
The source code that is evaluated to produce the Haml document.
This is automatically converted to the correct encoding
(see the :encoding
option).
50 51 52 53 54 |
# File 'lib/haml/temple_engine.rb', line 50
def precompiled
encoding = Encoding.find(@encoding || '')
return @precompiled.force_encoding(encoding) if encoding == Encoding::ASCII_8BIT
return @precompiled.encode(encoding)
end
|
#precompiled_method_return_value_with_haml_xss Also known as: precompiled_method_return_value
17 18 19 |
# File 'lib/haml/template.rb', line 17
def precompiled_method_return_value_with_haml_xss
"::Haml::Util.html_safe(#{precompiled_method_return_value_without_haml_xss})"
end
|
#precompiled_method_return_value_without_haml_xss
20 |
# File 'lib/haml/template.rb', line 20
alias_method :precompiled_method_return_value_without_haml_xss, :precompiled_method_return_value
|
#precompiled_with_ambles(local_names, after_preamble: '') ⇒ String
The source code that is evaluated to produce the Haml document.
This is automatically converted to the correct encoding
(see the :encoding
option).
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/haml/temple_engine.rb', line 66
def precompiled_with_ambles(local_names, after_preamble: '')
preamble = <<END.tr!("\n", ';')
begin
extend Haml::Helpers
_hamlout = @haml_buffer = Haml::Buffer.new(haml_buffer, #{Options.new(options).for_buffer.inspect})
_erbout = _hamlout.buffer
#{after_preamble}
END
postamble = <<END.tr!("\n", ';')
#{precompiled_method_return_value}
ensure
@haml_buffer = @haml_buffer.upper if @haml_buffer
end
END
"#{preamble}#{locals_code(local_names)}#{precompiled}#{postamble}"
end
|
#precompiled_with_return_value
56 57 58 |
# File 'lib/haml/temple_engine.rb', line 56
def precompiled_with_return_value
"#{precompiled};#{precompiled_method_return_value}"
end
|