Sha256: 8c4cfa72d4f5029e36d700ea86620456986c8546abde239fa504ee3812979e0c

Contents?: true

Size: 963 Bytes

Versions: 24

Compression:

Stored size: 963 Bytes

Contents

module Octopress
  module Ink
    module Tags
      class CaptureTag < Liquid::Block
        SYNTAX = /([[:word:]]+)\s*(\+=|\|\|=)?/o

        def initialize(tag_name, markup, tokens)
          @markup = markup
          super
        end

        def render(context)
          return unless markup = Helpers::Conditional.parse(@markup, context)
          if markup =~ Helpers::Var::HAS_FILTERS
            markup = $1
            filters = $2
          end

          if markup =~ SYNTAX
            var      = $1
            operator = $2
            value = super.lstrip

            unless value.nil? || filters.nil?
              value = Helpers::Var.render_filters(value, filters, context)
            end

            context = Helpers::Var.set_var(var, operator, value, context)
          else
            raise SyntaxError.new("Syntax Error in 'capture' - Valid syntax: capture [var]")
          end
          ''
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
octopress-ink-1.0.0.rc.11 lib/octopress-ink/tags/capture.rb
octopress-ink-1.0.0.rc.10 lib/octopress-ink/tags/capture.rb
octopress-ink-1.0.0.rc.9 lib/octopress-ink/tags/capture.rb
octopress-ink-1.0.0.rc.8 lib/octopress-ink/tags/capture.rb
octopress-ink-1.0.0.rc.7 lib/octopress-ink/tags/capture.rb
octopress-ink-1.0.0.rc.6 lib/octopress-ink/tags/capture.rb
octopress-ink-1.0.0.rc.5 lib/octopress-ink/tags/capture.rb
octopress-ink-1.0.0.rc.3 lib/octopress-ink/tags/capture.rb
octopress-ink-1.0.0.rc.2 lib/octopress-ink/tags/capture.rb
octopress-ink-1.0.0.rc.1 lib/octopress-ink/tags/capture.rb
octopress-ink-1.0.0.alpha.45 lib/octopress-ink/tags/capture.rb
octopress-ink-1.0.0.alpha.44 lib/octopress-ink/tags/capture.rb
octopress-ink-1.0.0.alpha.43 lib/octopress-ink/tags/capture.rb
octopress-ink-1.0.0.alpha.42 lib/octopress-ink/tags/capture.rb
octopress-ink-1.0.0.alpha.41 lib/octopress-ink/tags/capture.rb
octopress-ink-1.0.0.alpha.40 lib/octopress-ink/tags/capture.rb
octopress-ink-1.0.0.alpha.39 lib/octopress-ink/tags/capture.rb
octopress-ink-1.0.0.alpha.38 lib/octopress-ink/tags/capture.rb
octopress-ink-1.0.0.alpha.37 lib/octopress-ink/tags/capture.rb
octopress-ink-1.0.0.alpha.36 lib/octopress-ink/tags/capture.rb