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.
Class Method Summary collapse
-
.desc ⇒ Object
:nodoc:.
Instance Method Summary collapse
Class Method Details
.desc ⇒ Object
: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
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 |
# File 'lib/erubis/enhancer.rb', line 446 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 : $' # or $' || text unless text2.empty? text2 << rest if rest rest = text2 end super(src, rest) end |