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.2.0 lib/platformos_check/tags/export.rb
platformos-check-0.1.0 lib/platformos_check/tags/export.rb
platformos-check-0.0.3 lib/platformos_check/tags/export.rb
platformos-check-0.0.2 lib/platformos_check/tags/export.rb
platformos-check-0.0.1 lib/platformos_check/tags/export.rb