askama
askama copied to clipboard
Ignore whitespace between method name and argument list
The following simple template fails:
{{ model.test ("test-from-model") }}
Just by removing the whitespace between the test
and (...
solves the issue.
Yeah, I guess. I am unlikely to work on this anytime soon, but if you want to take a crack at implementing I could provide you with some pointers.
OK, could you give me the needed pointers?
(Although I agree it's low priority, given that my coding styles aren't inline with the 99%; however this weekend perhaps I'll take a look.)
You'll need to update https://github.com/djc/askama/blob/master/askama_shared/src/parser.rs#L307 (and probably also expr_path_call()
a few lines down) to eat the extra whitespace. Please also add test cases for any changes you make (could be either unit tests in the parser or full integration tests).
OK, trying to solve this issue, I've came across the following ambiguity in the language regarding filter application and bitwise-or.
Say I have the following two templates a|b
and a | b
:
- the first one
a|b
is interpreted as applying theb
filter toa
, when used fails complaining that the filterb
does not exist; - the second one
a | b
is interpreted as a bitwise operator betweena
andb
;
For example in the NestedFilterTemplate
x|mytrim|safe
if rewritten as x | mytrim | safe
fails by saying that safe
is not a member of the template.