Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The content_for tag should be supported by the parser and parse its arguments. #466

Closed
charlespwd opened this issue Aug 5, 2024 · 1 comment · Fixed by #568
Closed
Assignees
Labels

Comments

@charlespwd
Copy link
Contributor

charlespwd commented Aug 5, 2024

Describe the bug
Right now any kind of {% content_for 'block', id: something, name: something %} parses the markup as a flat string. It should be something easier to manage in checks/complete/etc instead.

https://shopify.dev/docs/api/liquid/tags#content_for

Source

{% content_for 'block', type: "", id: "" %}

Expected behaviour

const ast: LiquidHtmlNode = toLiquidHtmlAST(`{% content_for 'block', type: "", id: "" %}`);
const tag = ast.children[0];
assert(tag.name === 'content_for');
assert(tag.markup.type === 'ContentForMarkup');
// something like that
assert(tag.markup.contentForType  === 'block');
assert(tag.markup.kwargs.type === '...');

Actual behaviour

const ast: LiquidHtmlNode = toLiquidHtmlAST(`{% content_for 'block', type: "", id: "" %}`);
const tag = ast.children[0];
assert(tag.name === 'content_for');
// markup isn't a complex type, but a string! It means we need to do regex!
assert(typeof tag.markup === 'string');

Additional context

At the end of the day, we should be able to do "richer" completion and theme checks when it comes to that tag once we parse it better.

@charlespwd
Copy link
Contributor Author

e.g. stuff like this should be easier and safer to do!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant