You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
>>> from liquid import Environment
>>> env = Environment()
>>> env.from_string("{{thing['foo.bar']}}").analyze().variables # property "foo.bar" of thing
{'thing.foo.bar': [('<string>', 1)]}
>>> env.from_string("{{thing.foo.bar]}}").analyze().variables # property bar of property foo of thing
{'thing.foo.bar': [('<string>', 1)]}
thing['foo.bar'] and thing.foo.bar are distinct, but end up with the same representation. It would be helpful to be able to get a more structured representation (maybe with a keyword arg to analyze) so that thing['foo.bar'] is something like ('thing', 'foo.bar') and thing.foo.bar('thing', 'foo', 'bar').
The text was updated successfully, but these errors were encountered:
The string representation of variables has been fixed in version 1.6.0, and those strings now include a parts property, being a tuple representation of the variable. No extra arguments to analyze() required.
fromliquidimportEnvironmentenv=Environment()
template=env.from_string("{{ thing.foo.bar }} {{ thing['foo.bar'] }}")
forvar, locationintemplate.analyze().variables.items():
fortemplate_name, line_numberinlocation:
print(f"{var}{var.parts} found in '{template_name}' on line {line_number}")
output
thing.foo.bar ('thing', 'foo', 'bar') found in '<string>' on line 1
thing["foo.bar"] ('thing', 'foo.bar') found in '<string>' on line 1
thing['foo.bar']
andthing.foo.bar
are distinct, but end up with the same representation. It would be helpful to be able to get a more structured representation (maybe with a keyword arg to analyze) so thatthing['foo.bar']
is something like('thing', 'foo.bar')
andthing.foo.bar
('thing', 'foo', 'bar')
.The text was updated successfully, but these errors were encountered: