liquid
liquid copied to clipboard
Deterministic cycle keys
This pull request fixes #1519 by offering an alternative method for generating context keys for the cycle
tag when using "simple syntax".
Rather than using a string representation of objects returned from parse_expression()
, we combine the object's class name and input argument, separated by a hyphen.
For example, given a identifier that gets parsed to a Liquid::VariableLookup
, instead of a key containing something like "<Liquid::VariableLookup:0x00005632631bc858>"
, which changes with every occurrence of {% cycle %}
, we would get "VariableLookup-x"
. Where x
is the input argument.
Extra care has been taken to handle Liquid::C::Expression
objects. Hence the use of object.respond_to?(:evaluate)
and the reason for generating key strings at the same time as parsing each expression.