Unified syntax for tag arguments [RFC]
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 11.9k
- Forks
- 1.5k
- Avg merge
- 17h 55m
- Merged PRs (30d)
- 3
Description
Tags are currently implemented as an arbitrary syntax defined in their #initialize or #parse method. Some of them use a combination of Liquid's regexes to do parsing, but not in a consistent way. This makes updating the language difficult – in particular, phasing out the lax parser.
Filters, on the other hand, are simply passed an array (positional arguments) and hash (keyword arguments), and have no say in how they were parsed. This decoupling is a huge advantage, allowing fixes and improvements to affect all filters without breaking them.
So, the idea is automatically parse tags in a certain format, for example:
arg = id colon expr | expr
tag = id (arg (comma arg)*)?
Then, the tag can access the resulting arguments (i.e. values returned from Expression.parse).
Since we do still want certain tags to have custom syntax, we can't 100% separate parsing from the tag definition. Some kind of way to extend the default will be necessary. However, since most tags don't need this (maybe none outside of the core tags?), it still allows most of the parsing logic to be decoupled.
Tags that need partially custom syntax could still take advantage of the argument parsing, e.g. the for tag:
for foo in bar reversed, limit: 4, offset: 5
Does this make sense? @Shopify/liquid @parkr
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 comparing how tags parse arguments in their #initialize or #parse methods with how filters receive positional and keyword arguments. Define the default tag argument format and how tags with custom syntax extend it; done means common tag parsing is decoupled while custom cases remain supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100