Class: ThemeCheck::Tags::Form
- Inherits:
-
Liquid::Block
- Object
- Liquid::Block
- ThemeCheck::Tags::Form
- Defined in:
- lib/theme_check/tags.rb
Defined Under Namespace
Classes: ParseTreeVisitor
Constant Summary collapse
- TAG_ATTRIBUTES =
/([\w\-]+)\s*:\s*(#{Liquid::QuotedFragment})/o
- FORM_FORMAT =
Matches forms with arguments:
'type', object 'type', object, key: value, ... 'type', key: value, ...
old format: form product new format: form “product”, product, id: “newID”, class: “custom-class”, data-example: “100”
%r{ (?<type>#{Liquid::QuotedFragment}) (?:\s*,\s*(?<variable_name>#{Liquid::VariableSignature}+)(?!:))? (?<attributes>(?:\s*,\s*(?:#{TAG_ATTRIBUTES}))*)\s*\Z }xo
Instance Attribute Summary collapse
-
#tag_attributes ⇒ Object
readonly
Returns the value of attribute tag_attributes.
-
#type_expr ⇒ Object
readonly
Returns the value of attribute type_expr.
-
#variable_name_expr ⇒ Object
readonly
Returns the value of attribute variable_name_expr.
Instance Method Summary collapse
-
#initialize(tag_name, markup, options) ⇒ Form
constructor
A new instance of Form.
Constructor Details
#initialize(tag_name, markup, options) ⇒ Form
Returns a new instance of Form.
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/theme_check/tags.rb', line 42 def initialize(tag_name, markup, ) super @match = FORM_FORMAT.match(markup) raise Liquid::SyntaxError, "in 'form' - Valid syntax: form 'type'[, object]" unless @match @type_expr = parse_expression(@match[:type]) @variable_name_expr = parse_expression(@match[:variable_name]) tag_attributes = @match[:attributes].scan(TAG_ATTRIBUTES) tag_attributes.each do |kv_pair| kv_pair[1] = parse_expression(kv_pair[1]) end @tag_attributes = tag_attributes end |
Instance Attribute Details
#tag_attributes ⇒ Object (readonly)
Returns the value of attribute tag_attributes.
40 41 42 |
# File 'lib/theme_check/tags.rb', line 40 def tag_attributes @tag_attributes end |
#type_expr ⇒ Object (readonly)
Returns the value of attribute type_expr.
40 41 42 |
# File 'lib/theme_check/tags.rb', line 40 def type_expr @type_expr end |
#variable_name_expr ⇒ Object (readonly)
Returns the value of attribute variable_name_expr.
40 41 42 |
# File 'lib/theme_check/tags.rb', line 40 def variable_name_expr @variable_name_expr end |