Sha256: 56c3a4305d2e6a7f0d6c1de6cc58c724fd212427e5b2e79352b7da18607e03b9

Contents?: true

Size: 1.48 KB

Versions: 2

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

module Archangel
  module Liquid
    ##
    # Archangel custom Liquid tags
    #
    module Tags
      ##
      # Base helper class for Liquid
      #
      class ApplicationTag < ::Liquid::Tag
        include ::ActionView::Helpers::TagHelper

        ##
        # Regex for asset name
        #
        ASSET_SYNTAX = /
          #{::Liquid::QuotedString}
          |
          (
            [\w-]+\.[\w]+
            |
            #{::Liquid::QuotedString}
          )
        /ox

        ##
        # Regex for tag syntax
        #
        ASSET_ATTRIBUTES_SYNTAX = /
          (?<asset>#{ASSET_SYNTAX})
          \s*
          (?<attributes>.*)
          \s*
        /omx

        ##
        # Regex for "key: value" attributes
        #
        # Example
        #   {% tag_name "[slug]" [foo: bar, bat: "baz"] %}
        #
        KEY_VALUE_ATTRIBUTES_SYNTAX = /
          (?<key>\w+)
          \s*
          \:
          \s*
          (?<value>#{::Liquid::QuotedFragment})
        /ox

        ##
        # Slug and attributes syntax
        #
        # Example
        #   {% tag_name "[slug]" [attributes] %}
        #
        SLUG_ATTRIBUTES_SYNTAX = /
          (?<slug>#{::Liquid::QuotedFragment}+)
          \s*
          (?<attributes>.*)
          \s*
        /omx

        ##
        # Slug syntax
        #
        # Example
        #   {% tag_name "[slug]" %}
        #
        SLUG_SYNTAX = /(?<slug>#{::Liquid::QuotedFragment}+)\s*/o
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
archangel-0.0.8 lib/archangel/liquid/tags/application_tag.rb
archangel-0.0.7 lib/archangel/liquid/tags/application_tag.rb