Method: Liquid::Cycle#initialize

Defined in:
lib/liquid/tags/cycle.rb

#initialize(tag_name, markup, options) ⇒ Cycle

Returns a new instance of Cycle.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/liquid/tags/cycle.rb', line 23

def initialize(tag_name, markup, options)
  super
  case markup
  when NamedSyntax
    @variables = variables_from_string(Regexp.last_match(2))
    @name      = parse_expression(Regexp.last_match(1))
    @is_named = true
  when SimpleSyntax
    @variables = variables_from_string(markup)
    @name      = @variables.to_s
    @is_named = !@name.match?(/\w+:0x\h{8}/)
  else
    raise SyntaxError, options[:locale].t("errors.syntax.cycle")
  end
end