Class: Jeanny::TT2Template
- Defined in:
- lib/jeanny/engine.rb
Instance Attribute Summary
Attributes inherited from Code
Instance Method Summary collapse
Methods inherited from Code
Constructor Details
This class inherits a constructor from Jeanny::Code
Instance Method Details
#replace(classes) ⇒ Object
442 443 444 445 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 |
# File 'lib/jeanny/engine.rb', line 442 def replace classes = Array.new mark = self.object_id @code.gsub! /\[%(.*?)%\]/m do |tag| .push tag and "#{mark}:#{.length - 1}:" end super classes classes.each do |full_class, short_class| .map! do |tag| tag.gsub /((BLOCK|PROCESS|INCLUDE|INSERT)\s+('|").*?[^\\]\3)|(('|").*?[^\\]\5)/ do |string| unless $5.nil? string.gsub /#{full_class}(?=[\s"']|$|\\["'])/, short_class else string end end end end .select.with_index do |tag, index| @code.gsub! "#{mark}:#{index}:", tag end @code end |