Closed ronnodas closed 1 month ago
Thank you for the bug report! As the language is currently parsed, I don't think this is fixable. The parser sees a right shift >>
, so it wants to parse a binary operation. The string <<a>> and) <<b>>
is tokenized like: StartExpr
, Var(a)
, Op(">>")
, Var("and")
, Unexpected(")")
, …
We should explicitly reject terminators that start with >>
, <<
, ..
, &&
, or ||
, so you and other users get a proper error message.
That makes sense. It's weird that it works in the python/jinja project I'm porting from.
They probably first look for the terminator, then try to make sense of everything captured between the delimiters. There are pros and cons to both approaches.
It was fixed in #129 so I think it can be closed now. It'll be part of next release.
With
expr
delimiters<<
and>>
, trying to use the template<<a>> and <<b>>
complains aboutand
not being a field. Here is a full example that produces the error "no fieldand
on type&HelloTemplate
":Maybe worse, using
(<<a>> and) <<b>>
as the template produces "failed to parse template source".Everything works fine if the delimiters are changed to eg
<!
and!>
. I have not experimented with other pairs.The same issue also exists in askama, which I have filed as https://github.com/djc/askama/issues/1081.