Class: Tilt::ErubisTemplate

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

Instance Method Summary collapse

Methods inherited from ERBTemplate

#precompiled_template

Methods inherited from Template

#basename, #eval_file, #initialize, #name, #render

Constructor Details

This class inherits a constructor from Tilt::Template

Instance Method Details

#initialize_engineObject



415
416
417
418
# File 'lib/frank/tilt.rb', line 415

def initialize_engine
  return if defined? ::Erubis
  require_template_library 'erubis'
end

#precompiled(locals) ⇒ Object



439
440
441
442
# File 'lib/frank/tilt.rb', line 439

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

#precompiled_postamble(locals) ⇒ Object



432
433
434
# File 'lib/frank/tilt.rb', line 432

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

#precompiled_preamble(locals) ⇒ Object



428
429
430
# File 'lib/frank/tilt.rb', line 428

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

#prepareObject



420
421
422
423
424
425
426
# File 'lib/frank/tilt.rb', line 420

def prepare
  @options.merge!(:preamble => false, :postamble => false)
  @outvar = (options.delete(:outvar) || '_erbout').to_s
  engine_class = options.delete(:engine_class)
  engine_class = ::Erubis::EscapedEruby if options.delete(:escape_html)
  @engine = (engine_class || ::Erubis::Eruby).new(data, options)
end