Methods

Class/Module Index [+]

Quicksearch

Erubis::PercentLineEnhancer

regards lines starting with '%' as program code

this is for compatibility to eruby and ERB.

this is language-independent.

Public Instance Methods

add_text(src, text) click to toggle source
# File lib/erubis/enhancer.rb, line 449
def add_text(src, text)
  pos = 0
  text2 = ''
  text.scan(/^\%(.*?\r?\n)/) do
    line  = $1
    match = Regexp.last_match
    len   = match.begin(0) - pos
    str   = text[pos, len]
    pos   = match.end(0)
    if text2.empty?
      text2 = str
    else
      text2 << str
    end
    if line[0] == %%
      text2 << line
    else
      super(src, text2)
      text2 = ''
      add_stmt(src, line)
    end
  end
  #rest = pos == 0 ? text : $'             # ruby1.8
  rest = pos == 0 ? text : text[pos..-1]   # ruby1.9
  unless text2.empty?
    text2 << rest if rest
    rest = text2
  end
  super(src, rest)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.