Class: ErbEngine

Inherits:
Haml::Engine
  • Object
show all
Defined in:
lib/to_erb/erb_engine.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ ErbEngine

Returns a new instance of ErbEngine.



35
36
37
38
# File 'lib/to_erb/erb_engine.rb', line 35

def initialize(*args)
  @rubyparser = RubyParser.new
  super(*args)
end

Instance Method Details

#push_generated_script(text) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/to_erb/erb_engine.rb', line 49

def push_generated_script(text)
  sexp = @rubyparser.parse text
  if sexp.node_type == :call and sexp[2] == :attributes
    sexp[2] = :extended_attributes
    arglist = sexp[3]
    last_hash_arg = arglist[3]
    
    (1..(last_hash_arg.size-1)/2).each do |i|
      last_hash_arg[i*2] = @rubyparser.parse(last_hash_arg[i*2].to_s) 
    end
    text = Ruby2Ruby.new.process sexp
  end

  super(text)
end

#push_script(text, preserve_script, in_tag = false, preserve_tag = false, escape_html = false, nuke_inner_whitespace = false) ⇒ Object



40
41
42
43
# File 'lib/to_erb/erb_engine.rb', line 40

def push_script(text, preserve_script, in_tag = false, preserve_tag = false,
                escape_html = false, nuke_inner_whitespace = false)
  push_text "<%= #{text.strip} %>"
end

#push_silent(text, can_suppress = false) ⇒ Object



45
46
47
# File 'lib/to_erb/erb_engine.rb', line 45

def push_silent(text, can_suppress = false)
  push_text "<% #{text.strip} %>"
end