Sha256: 71d327d5479e2753dc0a78eb350de56848bdb0e0a2c023f3d86fd1d60c2ae190

Contents?: true

Size: 897 Bytes

Versions: 3

Compression:

Stored size: 897 Bytes

Contents

module Locomotive
  module Steam
    module Liquid
      module Tags

        class PathTo < ::Liquid::Tag

          include PathHelper

          Syntax = /(#{::Liquid::Expression}+)(#{::Liquid::TagAttributes}?)/

          def initialize(tag_name, markup, tokens, context)
            if markup =~ Syntax
              @handle = $1
              @_options = {}
              markup.scan(::Liquid::TagAttributes) do |key, value|
                @_options[key] = value
              end
            else
              raise SyntaxError.new("Syntax Error in 'path_to' - Valid syntax: path_to <page|page_handle|content_entry>(, locale: [fr|de|...], with: <page_handle>")
            end

            super
          end

          def render(context)
            render_path(context)
          end

        end

        ::Liquid::Template.register_tag('path_to', PathTo)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
locomotivecms_steam-0.1.2.pre.beta lib/locomotive/steam/liquid/tags/path_to.rb
locomotivecms_steam-0.1.1 lib/locomotive/steam/liquid/tags/path_to.rb
locomotivecms_steam-0.1.0 lib/locomotive/steam/liquid/tags/path_to.rb