Is your feature request related to a problem? Please describe.
Currently, a Nunjucks shortcode or custom tag like this...
{% test 'arg1', 'arg2', foo='bar', baz=5 %}
...will pass the following arguments to its function:
[ 'arg1', 'arg2', { __keywords: true, foo: 'bar', baz: 5 } ]
This makes a lot of sense to me and I'd like to see its behavior replicated in Liquid shortcodes.
Describe the solution you'd like
I wrote a parser for Liquid arguments, which (mostly) matches the moo lexer currently used for Liquid shortcodes, but also supports keyword arguments and mimics the above behavior.
I can submit this as a pull request, though I think it partially depends on #1058 and how 11ty handles async argument evaluations.
Describe alternatives you've considered
There are some slight differences between mine and the moo parser, which I think bring it closer to Liquid syntax but which could be (theoretically?) breaking:
- Whitespace / arg separators are
/,?[ \t\n\r]+/ instead of /[, \t]+/. So arg1 ,arg2 or arg1,,,arg2 would be invalid.
- Numbers only allow one dot:
/[0-9]+\.?[0-9]*/ instead of /[0-9]+\.*[0-9]*/
- Variables can only have periods separating valid variable names, i.e
foo.bar.baz and not ..foobar.baz.
I could bring it exactly in line with the moo lexer if that's preferred. I assume it might be possible to do this with moo too, though I haven't used it before.
Is your feature request related to a problem? Please describe.
Currently, a Nunjucks shortcode or custom tag like this...
...will pass the following arguments to its function:
This makes a lot of sense to me and I'd like to see its behavior replicated in Liquid shortcodes.
Describe the solution you'd like
I wrote a parser for Liquid arguments, which (mostly) matches the moo lexer currently used for Liquid shortcodes, but also supports keyword arguments and mimics the above behavior.
I can submit this as a pull request, though I think it partially depends on #1058 and how 11ty handles async argument evaluations.
Describe alternatives you've considered
There are some slight differences between mine and the moo parser, which I think bring it closer to Liquid syntax but which could be (theoretically?) breaking:
/,?[ \t\n\r]+/instead of/[, \t]+/. Soarg1 ,arg2orarg1,,,arg2would be invalid./[0-9]+\.?[0-9]*/instead of/[0-9]+\.*[0-9]*/foo.bar.bazand not..foobar.baz.I could bring it exactly in line with the moo lexer if that's preferred. I assume it might be possible to do this with moo too, though I haven't used it before.