Class: ThemeCheck::Tags::Paginate
- Inherits:
-
Liquid::Block
- Object
- Liquid::Block
- ThemeCheck::Tags::Paginate
- Defined in:
- lib/theme_check/tags.rb
Defined Under Namespace
Classes: ParseTreeVisitor
Constant Summary collapse
- SYNTAX =
/(?<liquid_variable_name>#{Liquid::QuotedFragment})\s*((?<by>by)\s*(?<page_size>#{Liquid::QuotedFragment}))?/
Instance Attribute Summary collapse
-
#page_size ⇒ Object
readonly
Returns the value of attribute page_size.
Instance Method Summary collapse
-
#initialize(tag_name, markup, options) ⇒ Paginate
constructor
A new instance of Paginate.
Constructor Details
#initialize(tag_name, markup, options) ⇒ Paginate
Returns a new instance of Paginate.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/theme_check/tags.rb', line 67 def initialize(tag_name, markup, ) super if (matches = markup.match(SYNTAX)) @liquid_variable_name = matches[:liquid_variable_name] @page_size = parse_expression(matches[:page_size]) @window_size = nil # determines how many pagination links are shown @liquid_variable_count_expr = parse_expression("#{@liquid_variable_name}_count") var_parts = @liquid_variable_name.rpartition('.') @source_drop_expr = parse_expression(var_parts[0].empty? ? var_parts.last : var_parts.first) @method_name = var_parts.last.to_sym markup.scan(Liquid::TagAttributes) do |key, value| case key when 'window_size' @window_size = value.to_i end end else raise(Liquid::SyntaxError, "in tag 'paginate' - Valid syntax: paginate [collection] by number") end end |
Instance Attribute Details
#page_size ⇒ Object (readonly)
Returns the value of attribute page_size.
65 66 67 |
# File 'lib/theme_check/tags.rb', line 65 def page_size @page_size end |