Skip to content

Commit 84639b6

Browse files
committed
Add named? method to Cycle class for checking if the cycle is named
1 parent 88d013c commit 84639b6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/liquid/tags/cycle.rb

+6
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,20 @@ def initialize(tag_name, markup, options)
2626
when NamedSyntax
2727
@variables = variables_from_string(Regexp.last_match(2))
2828
@name = parse_expression(Regexp.last_match(1))
29+
@is_named = true
2930
when SimpleSyntax
3031
@variables = variables_from_string(markup)
3132
@name = @variables.to_s
33+
@is_named = !@name.match?(/\w+:0x\h{8}/)
3234
else
3335
raise SyntaxError, options[:locale].t("errors.syntax.cycle")
3436
end
3537
end
3638

39+
def named?
40+
@is_named
41+
end
42+
3743
def render_to_output_buffer(context, output)
3844
context.registers[:cycle] ||= {}
3945

0 commit comments

Comments
 (0)