Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd tests to ensure parser requires whitespaces #379
Comments
Keats
added
bug
help wanted
labels
Jan 17, 2019
This comment has been minimized.
This comment has been minimized.
|
Here is the related test: // https://github.com/Keats/tera/issues/379
#[test]
fn lex_requires_whitespace_between_things() {
let inputs = vec![
"{% filterupper %}hey{% endfilter %}",
"{% fora in b %}{{a}}{% endfor %}",
"{% for a inb %}{{a}}{% endfor %}",
"{% ifi18n %}世界{% else %}world{% endif %}",
"{% ifi18n %}世界{% eliftrue %}world{% endif %}",
"{% blockhey %}{%endblock%}",
"{% macrohey() %}{%endmacro%}",
"{% setident = 1 %}",
"{% set_globalident = 1 %}",
"{% extends'base.html' %}",
"{% import 'macros/image.html' asimage %}",
"{% import'macros/image.html' as image %}",
];
for i in inputs {
let res = TeraParser::parse(Rule::template, i);
println!("{:?}", i);
assert!(res.is_err());
}
}if someone wants to get started on that. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Keats commentedJan 17, 2019
Seen on pest gitter:
Full discussion is https://gitter.im/pest-parser/pest?at=5c376ef8317e2407cd0e3651
In short it means that
{%- ifname %}will be considered validThis is not intended and should be fixed on the v1 branch.
The first step is to have failing tests for all this kind of missing whitespace issue and then fix the grammar. It could be a nice occasion to clean up the grammar at the same time, there are enough tests that it should be fairly safe to do big changes.