Class: Jeanny::TT2Template

Inherits:
HTMLCode show all
Defined in:
lib/jeanny/engine.rb

Instance Attribute Summary

Attributes inherited from Code

#code

Instance Method Summary collapse

Methods inherited from Code

#initialize

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

    tags = Array.new
    mark = self.object_id

    @code.gsub! /\[%(.*?)%\]/m do |tag|
        tags.push tag and "#{mark}:#{tags.length - 1}:"
    end

    super classes

    classes.each do |full_class, short_class|
        tags.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

    tags.select.with_index do |tag, index|
        @code.gsub! "#{mark}:#{index}:", tag
    end

    @code
    
end