Class: ERB

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-vpi/erb.rb

Overview

A version of ERB whose embedding tags behave like those of PHP. That is, only <%= … %> tags produce output, whereas <% … %> tags do not produce any output.

Instance Method Summary collapse

Constructor Details

#initialize(aInput, *aArgs) ⇒ ERB

Returns a new instance of ERB.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ruby-vpi/erb.rb', line 14

def initialize aInput, *aArgs
  # ensure that only <%= ... %> tags generate output
    input = aInput.gsub %r{<%=.*?%>}m do |s|
      if ($' =~ /\r?\n/) == 0
        s << $&
      else
        s
      end
    end

    aArgs[1] = '>'

  original_initialize input, *aArgs
end

Instance Method Details

#original_initializeObject



12
# File 'lib/ruby-vpi/erb.rb', line 12

alias original_initialize initialize