Skip to content

Commit

Permalink
Add named? method to Cycle class for checking if the cycle is named
Browse files Browse the repository at this point in the history
  • Loading branch information
Maaarcocr authored and ianks committed Jul 16, 2024
1 parent 77bc56a commit d36937d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/liquid/tags/cycle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,20 @@ def initialize(tag_name, markup, options)
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

def named?
@is_named
end

def render_to_output_buffer(context, output)
context.registers[:cycle] ||= {}

Expand Down

0 comments on commit d36937d

Please sign in to comment.