Add keyword arguments for Liquid shortcodes.#1269
Add keyword arguments for Liquid shortcodes.#1269dawaltconley wants to merge 3 commits into11ty:masterfrom
Conversation
|
@dawaltconley this feature looks great, and you did a really good job with The breaking changes seem sensible. Do you think you could write some examples in terms of what's changed for consumers? Particularly if breaking E.g.: Previously, the following arguments would be parsed: Now, argument parsing is more strict and this should be changed to: Etc... |
|
Honestly, I wrote it for myself and was halfway done by the time I thought of integrating it into 11ty. :P Otherwise I might have tried to figure it out with moo. I'm more familiar with PEG.js and probably not the best person to tackle it with moo but would be down to try if y'all think that's better. I assume any change to the current lexer will be only as well-tested as the 11ty tests allow, but I should probably write more tests for liquid-args anyway, including testing for expected failures. And yes, down to write up the breaking changes, should have time this week. Currently this would also break: And the parser should probably be able to handle that at least. Will update. |
|
Sorry for the late reply here. Definitely a fan of this and seems like it might be a good fit for 1.0 as long as the breaking changes aren’t too drastic. I am worried about |
|
Howdy y’all—still interested in this one! |
|
Howdy thanks for the bump and sorry for the delay on this! Going back to it it looks like I fixed the white space issue, so commas with no spaces a la It's pretty arbitrary; it parses white space as Will submit a new pull request with details re breaking changes. |
Fixes #1263. This removes
mooand switches the argument lexer/parser for Liquid shortcodes to liquid-args, to support keyword arguments. Grammar is here but basically the differences are:/,?[ \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.1 could be breaking if people are getting freaky with their commas (and I'm not wed to it, could keep as is). The differences in 2 & 3 should only throw errors in cases that would also cause a Liquid rendering error.
I added some (possibly too many) tests as well, basically copying old tests and updating them to use keywords.