Class: Tilt::ErubisTemplate
- Inherits:
-
ERBTemplate
- Object
- Template
- ERBTemplate
- Tilt::ErubisTemplate
- Defined in:
- lib/tilt/erubis.rb
Overview
Erubis template implementation. See: www.kuwata-lab.com/erubis/
ErubisTemplate supports the following additional options, which are not passed down to the Erubis engine:
:engine_class allows you to specify a custom engine class to use
instead of the default (which is ::Erubis::Eruby).
:escape_html when true, ::Erubis::EscapedEruby will be used as
the engine class instead of the default. All content
within <%= %> blocks will be automatically html escaped.
Constant Summary
Constants inherited from ERBTemplate
Tilt::ERBTemplate::SUPPORTS_KVARGS
Instance Attribute Summary
Attributes inherited from Template
#compiled_path, #data, #file, #line, #options
Instance Method Summary collapse
- #freeze_string_literals? ⇒ Boolean
-
#precompiled(locals) ⇒ Object
Erubis doesn’t have ERB’s line-off-by-one under 1.9 problem.
- #precompiled_postamble(locals) ⇒ Object
- #precompiled_preamble(locals) ⇒ Object
- #prepare ⇒ Object
Methods inherited from ERBTemplate
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
#freeze_string_literals? ⇒ Boolean
47 48 49 |
# File 'lib/tilt/erubis.rb', line 47 def freeze_string_literals? @freeze_string_literals end |
#precompiled(locals) ⇒ Object
Erubis doesn’t have ERB’s line-off-by-one under 1.9 problem. Override and adjust back.
42 43 44 45 |
# File 'lib/tilt/erubis.rb', line 42 def precompiled(locals) source, offset = super [source, offset - 1] end |
#precompiled_postamble(locals) ⇒ Object
36 37 38 |
# File 'lib/tilt/erubis.rb', line 36 def precompiled_postamble(locals) [@outvar, super].join("\n") end |
#precompiled_preamble(locals) ⇒ Object
32 33 34 |
# File 'lib/tilt/erubis.rb', line 32 def precompiled_preamble(locals) [super, "#{@outvar} = _buf = String.new"].join("\n") end |
#prepare ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/tilt/erubis.rb', line 21 def prepare @freeze_string_literals = !!@options.delete(:freeze) @outvar = @options.delete(:outvar) || '_erbout' @options[:preamble] = false @options[:postamble] = false @options[:bufvar] = @outvar engine_class = @options.delete(:engine_class) engine_class = ::Erubis::EscapedEruby if @options.delete(:escape_html) @engine = (engine_class || ::Erubis::Eruby).new(@data, @options) end |