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

Parser does not catch variable syntax error #60

Closed
prsnca opened this issue Feb 28, 2018 · 3 comments
Closed

Parser does not catch variable syntax error #60

prsnca opened this issue Feb 28, 2018 · 3 comments

Comments

@prsnca
Copy link

prsnca commented Feb 28, 2018

The original liquid ruby gem fails on parsing if this case is given:
{{ user_name }
and generates this error:
Liquid syntax error: Variable '{{ user_name }' was not properly terminated with regexp: /\}\}/
I would expect this parser to catch these syntax errors as well and return a ParseError.
When trying to parse something with this syntax error, the tokenizer returns 'nested endless hash' or i don't know how to name it :)
screen shot 2018-02-28 at 10 56 31 am

I have looked through the config and haven't found anything that will help me :/
@harttle - I'm willing to contribute on this - just give me some guidance ;)

Thanks!

@harttle
Copy link
Owner

harttle commented Feb 28, 2018

Currently the tokenizer uses a regex-based loop to find all OutputTokens and TagTokens, and characters between them are parsed as HTMLTokens. So there's no exception thrown out for unmatched outputs and tags.

I agree that the parse loop should be implemented manually, iterate character by character for example. We'll have fine-grained control over that process, so we can throw the exceptions you expected.

You can find the source code for the tokenizer here: https://github.com/harttle/liquidjs/blob/master/src/tokenizer.js And test cases here: https://github.com/harttle/liquidjs/blob/master/test/tokenizer.js

@harttle
Copy link
Owner

harttle commented Jan 28, 2019

Should be resolved along with #89 after re-implement the tokenizer.

@harttle
Copy link
Owner

harttle commented Feb 21, 2019

Now supported since @7.1.0 by this commit. Closing.

@harttle harttle closed this as completed Feb 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants