Module | Erubis::PercentLineEnhancer |
In: |
lib/erubis/enhancer.rb
|
regards lines starting with ’%’ as program code
this is for compatibility to eruby and ERB.
this is language-independent.
# File lib/erubis/enhancer.rb, line 450 450: def add_text(src, text) 451: pos = 0 452: text2 = '' 453: text.scan(/^\%(.*?\r?\n)/) do 454: line = $1 455: match = Regexp.last_match 456: len = match.begin(0) - pos 457: str = text[pos, len] 458: pos = match.end(0) 459: if text2.empty? 460: text2 = str 461: else 462: text2 << str 463: end 464: if line[0] == ?% 465: text2 << line 466: else 467: super(src, text2) 468: text2 = '' 469: add_stmt(src, line) 470: end 471: end 472: #rest = pos == 0 ? text : $' # ruby1.8 473: rest = pos == 0 ? text : text[pos..-1] # ruby1.9 474: unless text2.empty? 475: text2 << rest if rest 476: rest = text2 477: end 478: super(src, rest) 479: end