Class: EZML::TemplateEngine
- Defined in:
- lib/ezml/template_engine.rb
Instance Method Summary collapse
- #compile(template) ⇒ Object
- #precompiled ⇒ Object
- #precompiled_with_ambles(local_names, after_preamble: '') ⇒ Object
- #precompiled_with_return_value ⇒ Object
Instance Method Details
#compile(template) ⇒ Object
38 39 40 41 |
# File 'lib/ezml/template_engine.rb', line 38 def compile(template) initialize_encoding(template, [:encoding]) @precompiled = call(template) end |
#precompiled ⇒ Object
43 44 45 46 47 |
# File 'lib/ezml/template_engine.rb', line 43 def precompiled encoding = Encoding.find(@encoding || '') return @precompiled.dup.force_encoding(encoding) if encoding == Encoding::ASCII_8BIT return @precompiled.encode(encoding) end |
#precompiled_with_ambles(local_names, after_preamble: '') ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ezml/template_engine.rb', line 53 def precompiled_with_ambles(local_names, after_preamble: '') preamble = <<END.tr("\n", ';') begin extend EZML::Helpers _ezmlout = @ezml_buffer = EZML::Buffer.new(ezml_buffer, #{Options.new().for_buffer.inspect}) _erbout = _ezmlout.buffer #{after_preamble} END postamble = <<END.tr("\n", ';') #{precompiled_method_return_value} ensure @ezml_buffer = @ezml_buffer.upper if @ezml_buffer end END "#{preamble}#{locals_code(local_names)}#{precompiled}#{postamble}".dup end |
#precompiled_with_return_value ⇒ Object
49 50 51 |
# File 'lib/ezml/template_engine.rb', line 49 def precompiled_with_return_value "#{precompiled};#{precompiled_method_return_value}".dup end |