Class: Tilt::ErubisTemplate

Inherits:
ERBTemplate show all
Defined in:
lib/vendor/tilt-1.4.1/lib/tilt/erb.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.

Instance Attribute Summary

Attributes inherited from Template

#data, #file, #line, #options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ERBTemplate

default_output_variable, default_output_variable=, #precompiled_template

Methods inherited from Template

#allows_script?, #basename, #default_encoding, #eval_file, #initialize, #name, #read_template_file, #render

Constructor Details

This class inherits a constructor from Tilt::Template

Class Method Details

.engine_initialized?Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/vendor/tilt-1.4.1/lib/tilt/erb.rb', line 76

def self.engine_initialized?
  defined? ::Erubis::Eruby
end

Instance Method Details

#initialize_engineObject



80
81
82
# File 'lib/vendor/tilt-1.4.1/lib/tilt/erb.rb', line 80

def initialize_engine
  require_template_library 'erubis'
end

#precompiled(locals) ⇒ Object



103
104
105
106
# File 'lib/vendor/tilt-1.4.1/lib/tilt/erb.rb', line 103

def precompiled(locals)
  source, offset = super
  [source, offset - 1]
end

#precompiled_postamble(locals) ⇒ Object



96
97
98
# File 'lib/vendor/tilt-1.4.1/lib/tilt/erb.rb', line 96

def precompiled_postamble(locals)
  [@outvar, super].join("\n")
end

#precompiled_preamble(locals) ⇒ Object



92
93
94
# File 'lib/vendor/tilt-1.4.1/lib/tilt/erb.rb', line 92

def precompiled_preamble(locals)
  [super, "#{@outvar} = _buf = ''"].join("\n")
end

#prepareObject



84
85
86
87
88
89
90
# File 'lib/vendor/tilt-1.4.1/lib/tilt/erb.rb', line 84

def prepare
  @outvar = options.delete(:outvar) || self.class.default_output_variable
  @options.merge!(:preamble => false, :postamble => false, :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