Sha256: 7a9fd04eb41f98b8eb8570aaf2d8abe0147ebf5ca7b04ca6339b71521f23ad93

Contents?: true

Size: 428 Bytes

Versions: 24

Compression:

Stored size: 428 Bytes

Contents

module AutoHtml
  class Builder
    @@filters = {}

    def initialize(text)
      @text = text.dup
    end

    def self.add_filter(name, &block)
      filter = Filter.new(block)
      @@filters.merge!(name => filter)
      src = %|
        def #{name}(options = {})
          @text = @@filters["#{name}".to_sym].apply(@text, options)
        end
      |
      class_eval src, __FILE__, __LINE__
      filter
    end
  end
end

Version data entries

24 entries across 24 versions & 2 rubygems

Version Path
auto_html-1.3.3 lib/auto_html/builder.rb
auto_html-1.3.2 lib/auto_html/builder.rb
auto_html-1.3.1 lib/auto_html/builder.rb
auto_html-1.3.0 lib/auto_html/builder.rb