Class: ThemeCheck::Tags::Section

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

Overview

Copied tags parsing code from storefront-renderer

Constant Summary collapse

SYNTAX =
/\A\s*(?<section_name>#{Liquid::QuotedString})\s*\z/o

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, markup, options) ⇒ Section

Returns a new instance of Section.

Raises:

  • (Liquid::SyntaxError)


12
13
14
15
16
17
18
19
20
21
22
# File 'lib/theme_check/tags.rb', line 12

def initialize(tag_name, markup, options)
  super

  match = markup.match(SYNTAX)
  raise(
    Liquid::SyntaxError,
    "Error in tag 'section' - Valid syntax: section '[type]'",
  ) unless match
  @section_name = match[:section_name].tr(%('"), '')
  @section_name.chomp!(".liquid") if @section_name.end_with?(".liquid")
end

Instance Attribute Details

#section_nameObject (readonly)

Returns the value of attribute section_name.



10
11
12
# File 'lib/theme_check/tags.rb', line 10

def section_name
  @section_name
end