Class: ThemeCheck::Tags::Render
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- ThemeCheck::Tags::Render
- Defined in:
- lib/theme_check/tags.rb
Defined Under Namespace
Classes: ParseTreeVisitor
Constant Summary collapse
- SYNTAX =
%r{ ( ## for {% render "snippet" %} #{Liquid::QuotedString}+ | ## for {% render block %} ## We require the variable # segment to be at the beginning of the ## string (with \A). This is to prevent code like {% render !foo! %} ## from parsing \A#{Liquid::VariableSegment}+ ) ## for {% render "snippet" with product as p %} ## or {% render "snippet" for products p %} (\s+(with|#{Liquid::Render::FOR})\s+(#{Liquid::QuotedFragment}+))? (\s+(?:as)\s+(#{Liquid::VariableSegment}+))? ## variables passed into the tag (e.g. {% render "snippet", var1: value1, var2: value2 %} ## are not matched by this regex and are handled by Liquid::Render.initialize }xo
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#template_name_expr ⇒ Object
readonly
Returns the value of attribute template_name_expr.
-
#variable_name_expr ⇒ Object
readonly
Returns the value of attribute variable_name_expr.
Instance Method Summary collapse
-
#initialize(tag_name, markup, options) ⇒ Render
constructor
A new instance of Render.
Constructor Details
#initialize(tag_name, markup, options) ⇒ Render
Returns a new instance of Render.
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/theme_check/tags.rb', line 150 def initialize(tag_name, markup, ) super raise Liquid::SyntaxError, [: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
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
148 149 150 |
# File 'lib/theme_check/tags.rb', line 148 def attributes @attributes end |
#template_name_expr ⇒ Object (readonly)
Returns the value of attribute template_name_expr.
148 149 150 |
# File 'lib/theme_check/tags.rb', line 148 def template_name_expr @template_name_expr end |
#variable_name_expr ⇒ Object (readonly)
Returns the value of attribute variable_name_expr.
148 149 150 |
# File 'lib/theme_check/tags.rb', line 148 def variable_name_expr @variable_name_expr end |