Class: ThemeCheck::Tags::Render

Inherits:
Liquid::Tag
  • Object
show all
Defined in:
lib/theme_check/tags.rb

Defined Under Namespace

Classes: ParseTreeVisitor

Constant Summary collapse

SYNTAX =
/((?:#{Liquid::QuotedString}|#{Liquid::VariableSegment})+)(\s+(with|#{Liquid::Render::FOR})\s+(#{Liquid::QuotedFragment}+))?(\s+(?:as)\s+(#{Liquid::VariableSegment}+))?/o

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, markup, options) ⇒ Render

Returns a new instance of Render.

Raises:



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/theme_check/tags.rb', line 135

def initialize(tag_name, markup, options)
  super

  raise SyntaxError, options[:locale].t("errors.syntax.render") unless markup =~ SYNTAX

  template_name = Regexp.last_match(1)
  with_or_for = Regexp.last_match(3)
  variable_name = Regexp.last_match(4)

  @alias_name = Regexp.last_match(6)
  @variable_name_expr = variable_name ? parse_expression(variable_name) : nil
  @template_name_expr = parse_expression(template_name)
  @for = (with_or_for == Liquid::Render::FOR)

  @attributes = {}
  markup.scan(Liquid::TagAttributes) do |key, value|
    @attributes[key] = parse_expression(value)
  end
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



133
134
135
# File 'lib/theme_check/tags.rb', line 133

def attributes
  @attributes
end

#template_name_exprObject (readonly)

Returns the value of attribute template_name_expr.



133
134
135
# File 'lib/theme_check/tags.rb', line 133

def template_name_expr
  @template_name_expr
end