Sha256: 7dfb73b1cd2129c8d7044b679ac4bd3ec126c887ab396eddf8cda0c9dd31d604

Contents?: true

Size: 510 Bytes

Versions: 6

Compression:

Stored size: 510 Bytes

Contents

module Awestruct
  module Extensions
    class Gsub      
      def initialize(pattern, replacement, options = {})
        @pattern = pattern
        @replacement = replacement
        @gsub_required = options[:gsub_required] || lambda { |site, page| page.output_path.end_with?(".html") }
      end
      
      def transform(site, page, rendered)
        if (@gsub_required.call(site, page))
          rendered = rendered.gsub(@pattern, @replacement)
        end
        rendered
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
awestruct-0.2.11 lib/awestruct/extensions/gsub.rb
awestruct-0.2.10 lib/awestruct/extensions/gsub.rb
awestruct-0.2.9 lib/awestruct/extensions/gsub.rb
awestruct-0.2.8 lib/awestruct/extensions/gsub.rb
awestruct-0.2.7 lib/awestruct/extensions/gsub.rb
awestruct-0.2.6 lib/awestruct/extensions/gsub.rb