Ah hah!  I just figured this out.

The problem was that I had an unterminated double-quoted string literal 
earlier in my template.  Apparently, this doesn't cause an exception, but 
instead breaks all other double-quoted string literals in my template.  
Single-quoted literals are still parsed correctly.

So, maybe the bug report here is: misleading failures as a result of 
unterminated string literals?

On Monday, October 1, 2018 at 5:10:01 PM UTC-7, Jonathan Mayer wrote:
>
> I just noticed surprising behavior when comparing a field against string 
> literals.
>
> {%- if foo == "bar" %}
>
> Produces the following error:
>
> jinja2.exceptions.TemplateSyntaxError: expected token 'end of statement 
> block', got 'bar'
>
> I can resolve this problem by replacing the double-quoted string literal 
> with a single-quote string literal.  This works:
>
> {%- if foo == 'bar' %}
>
> Why don't the two kinds of string literals behave the same?
>
> This might be specific to my environment, which is version 2.10 running in 
> a python2.7 environment with utf-8 encoded strings.  I haven't really done 
> my due diligence to make a standalone reproduction case yet, but I'm still 
> throwing my observation onto the list in case anybody else has encountered 
> this before, too.
>

-- 
You received this message because you are subscribed to the Google Groups 
"pocoo-libs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pocoo-libs+unsubscr...@googlegroups.com.
To post to this group, send email to pocoo-libs@googlegroups.com.
Visit this group at https://groups.google.com/group/pocoo-libs.
For more options, visit https://groups.google.com/d/optout.

Reply via email to