Sha256: 4af373dc92cbaf55ce51d6550d2878b2414ec82f19a801bc710b6742684e8908

Contents?: true

Size: 860 Bytes

Versions: 25

Compression:

Stored size: 860 Bytes

Contents

# frozen_string_literal: true

module PlatformosCheck
  module Tags
    class Export < Liquid::Tag
      SYNTAX = /\A([\w-]+[\s,]*[\w\s,]*)\s*(namespace:\s*(.+))?\z/

      attr_reader :namespace, :variables

      def initialize(tag_name, markup, options)
        super
        raise Liquid::SyntaxError, "Syntax Error in 'export' - Valid syntax: export [var1], [var2], ..., namespace: [namespace]" unless markup =~ SYNTAX

        @variables = Regexp.last_match(1).split(',').map { |v| Liquid::Expression.parse(v) }
        @namespace = Liquid::Expression.parse(Regexp.last_match(3)&.strip)
      end

      def parse_main_value(_tag_name, _markup); end

      class ParseTreeVisitor < Liquid::ParseTreeVisitor
        def children
          @node.variables +
            [
              @node.namespace
            ]
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
platformos-check-0.4.14 lib/platformos_check/tags/export.rb
platformos-check-0.4.13 lib/platformos_check/tags/export.rb
platformos-check-0.4.12 lib/platformos_check/tags/export.rb
platformos-check-0.4.11 lib/platformos_check/tags/export.rb
platformos-check-0.4.10 lib/platformos_check/tags/export.rb
platformos-check-0.4.9 lib/platformos_check/tags/export.rb
platformos-check-0.4.8 lib/platformos_check/tags/export.rb
platformos-check-0.4.7 lib/platformos_check/tags/export.rb
platformos-check-0.4.6 lib/platformos_check/tags/export.rb
platformos-check-0.4.5 lib/platformos_check/tags/export.rb
platformos-check-0.4.4 lib/platformos_check/tags/export.rb
platformos-check-0.4.3 lib/platformos_check/tags/export.rb
platformos-check-0.4.2 lib/platformos_check/tags/export.rb
platformos-check-0.4.1 lib/platformos_check/tags/export.rb
platformos-check-0.4.0 lib/platformos_check/tags/export.rb
platformos-check-0.3.3 lib/platformos_check/tags/export.rb
platformos-check-0.3.1 lib/platformos_check/tags/export.rb
platformos-check-0.3.0 lib/platformos_check/tags/export.rb
platformos-check-0.2.2 lib/platformos_check/tags/export.rb
platformos-check-0.2.1 lib/platformos_check/tags/export.rb