Module: Erubis::PercentLineEnhancer

Included in:
PercentLineEruby
Defined in:
lib/erubis/enhancer.rb

Overview

regards lines starting with ‘%’ as program code

this is for compatibility to eruby and ERB.

this is language-independent.

Constant Summary collapse

PERCENT_LINE_PATTERN =
/(.*?)^\%(.*?\r?\n)/m

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.descObject

:nodoc:



442
443
444
# File 'lib/erubis/enhancer.rb', line 442

def self.desc   # :nodoc:
  "regard lines starting with '%' as program code"
end

Instance Method Details

#add_text(src, text) ⇒ Object



448
449
450
451
452
453
454
455
456
457
458
459
# File 'lib/erubis/enhancer.rb', line 448

def add_text(src, text)
  text.scan(PERCENT_LINE_PATTERN) do |txt, line|
    super(src, txt)
    if line[0] == ?%
      super(src, line)
    else
      add_stmt(src, line)
    end
  end
  rest = $' || text
  super(src, rest)
end