Sha256: 897acef072d8b45eabc1a529ca62f8ee4472e6183c4b26d5587bf456e0441249

Contents?: true

Size: 600 Bytes

Versions: 2

Compression:

Stored size: 600 Bytes

Contents

# encoding: utf-8

#
# bracket links are links in the form [[label => target]] or [[page-name]]
#

module Amber
  module Render
    module Filter
      module Variables

        # variable expansion uses {{ }}
        VARIABLES_RE = /
          \{\{          # start {{
          ([^\{\}]+)    # $text : one or more characters that are not { or } ($1)
          \}\}          # end }}
        /x

        def self.run(text, &block)
          text.gsub(VARIABLES_RE) do |m|
            variable_name = $~[1].strip
            yield(variable_name)
          end
        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
amber-0.3.12 lib/amber/render/filter/variables.rb
amber-0.3.11 lib/amber/render/filter/variables.rb