Class: Malt::Engines::Erubis

Inherits:
Abstract show all
Defined in:
lib/malt/engines/erubis.rb

Overview

Erubis template implementation.

http://www.kuwata-lab.com/erubis/

Erubis is essentially compatibel with ERB, but it is faster.

Instance Attribute Summary

Attributes inherited from Abstract

#settings

Instance Method Summary collapse

Methods inherited from Abstract

#cache?, default, #initialize, register

Constructor Details

This class inherits a constructor from Malt::Engines::Abstract

Instance Method Details

#compile(params) ⇒ Object

Compile template into Ruby source code.



24
25
26
27
28
# File 'lib/malt/engines/erubis.rb', line 24

def compile(params)
  text = params[:text]
  file = params[:file]
  intermediate(text, file).src
end

#intermediate(params) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/malt/engines/erubis.rb', line 31

def intermediate(params)
  text = params[:text]
  file = params[:file]

  opts = {}

  if params[:escape_html] || settings[:escape_html]
    ::Erubis::EscapedEruby.new(text, settings)
  else
    ::Erubis::Eruby.new(text, settings)
  end
end

#render(params, &yld) ⇒ Object

Render template.



16
17
18
19
20
21
# File 'lib/malt/engines/erubis.rb', line 16

def render(params, &yld)
  text = params[:text]
  data = params[:data]
  data = make_binding(data, &yld)
  intermediate(params).result(data)
end

#safeObject



45
46
47
# File 'lib/malt/engines/erubis.rb', line 45

def safe
  options[:safe]
end

#trimObject



50
51
52
# File 'lib/malt/engines/erubis.rb', line 50

def trim
  options[:trim]
end