Clarification on default filter syntax for Object/Hash creation
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 11.9k
- Forks
- 1.5k
- Avg merge
- 17h 55m
- Merged PRs (30d)
- 3
Description
Couldn't simply find something in the dev docs. Is this an intentional and supported feature?
It is currently possible to use the assign tag with a default filter to define key-value pairs for an object, as shown below:
{% comment %} Example from the documentation {% endcomment %}
{% assign client_address = client_address | default: street: "Innovation Drive 22", city: "Capital City" %}
{% assign client = client | default: name: "Future Solutions Ltd.", address: client_address %}
This effectively creates a nested hash, which can then be accessed using standard dot notation:
{{ client.name }} // Outputs: Future Solutions Ltd.
{{ client.address.street }} // Outputs: Innovation Drive 22
This appears to be a very powerful and clean way to create hashes or objects directly within a Liquid template, which is a significant improvement over more complex workarounds like using capture with dynamic variable names or delimited strings, that we currently use a lot in Silverfin templates.
My Questions
- Is this
defaultfilter syntax for creating hashes an intentional and officially supported feature of Shopify's core Liquid library? - If this is a standard feature, could you please point me to the official documentation for it? I was unable to find any mention of this specific usage in the Shopify Liquid documentation.
- Is this behavior dependent on a specific version of Liquid?
- If this is not a core feature, is it possible that this is a custom filter or extension implemented by the Silverfin platform?
Thank you for your time and for providing clarity on this matter.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by checking the reported assign and default syntax against the project’s documented filter behavior and supported Liquid versions. Done means confirming whether nested hash creation is core behavior or an extension, then documenting the answer or directing users to the relevant documentation.
Written by the indexing model from the issue text.
Assessment
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100