Sha256: ae405d0bed24939a7cd6cc252988f7df71254e00a543f9098f8c1b60c4286fa9
Contents?: true
Size: 1.95 KB
Versions: 2
Compression:
Stored size: 1.95 KB
Contents
# frozen_string_literal: true module PlatformosCheck module Tags class Background < Base PARTIAL_SYNTAX = /(#{Liquid::VariableSignature}+)\s*=\s*(.*)\s*/om CLOSE_TAG_SYNTAX = /\A(.*)(?-mix:\{%-?)\s*(\w+)\s*(.*)?(?-mix:%\})\z/m # based on Liquid::Raw::FullTokenPossiblyInvalid attr_reader :to, :from, :attributes, :value_expr def initialize(tag_name, markup, options) if markup =~ PARTIAL_SYNTAX super @to = Regexp.last_match(1) @partial_syntax = true after_assign_markup = Regexp.last_match(2).split('|') parse_markup(tag_name, after_assign_markup.shift) after_assign_markup.unshift(@to) @from = Liquid::Variable.new(after_assign_markup.join('|'), options) else @partial_syntax = false parse_markup(tag_name, markup) super end end def parse(tokens) return super if @partial_syntax @body = +'' while (token = tokens.send(:shift)) if token =~ CLOSE_TAG_SYNTAX && block_delimiter == Regexp.last_match(2) @body << Regexp.last_match(1) if Regexp.last_match(1) != '' return end @body << token unless token.empty? end raise Liquid::SyntaxError, parse_context.locale.t('errors.syntax.tag_never_closed', block_name:) end def block_name @tag_name end def block_delimiter @block_delimiter = "end#{block_name}" end def parse_main_value(tag_name, markup) raise Liquid::SyntaxError, "Invalid syntax for #{tag_name} tag" unless markup =~ syntax @main_value = Regexp.last_match(1) @value_expr = @main_value ? Liquid::Expression.parse(@main_value) : nil end class ParseTreeVisitor < Liquid::ParseTreeVisitor def children [ @node.to ].compact + @node.attributes_expr.values end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
platformos-check-0.0.2 | lib/platformos_check/tags/background.rb |
platformos-check-0.0.1 | lib/platformos_check/tags/background.rb |