From c0f9fe973e6ff608f4f02f8a6cd39f2e9c50ea5c Mon Sep 17 00:00:00 2001 From: bott Date: Thu, 13 Sep 2018 23:40:17 +0200 Subject: Fix operator preference at loop.first --- askama_derive/src/generator.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'askama_derive') diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs index 5a136fb..d0ac030 100644 --- a/askama_derive/src/generator.rs +++ b/askama_derive/src/generator.rs @@ -747,14 +747,14 @@ impl<'a> Generator<'a> { fn visit_attr(&mut self, buf: &mut Buffer, obj: &Expr, attr: &str) -> DisplayWrap { if let Expr::Var(name) = *obj { if name == "loop" { - buf.write("_loop_index"); if attr == "index" { - buf.write(" + 1"); + buf.write("_loop_index + 1"); return DisplayWrap::Unwrapped; } else if attr == "index0" { + buf.write("_loop_index"); return DisplayWrap::Unwrapped; } else if attr == "first" { - buf.write(" == 0"); + buf.write("(_loop_index == 0)"); return DisplayWrap::Unwrapped; } else { panic!("unknown loop variable"); -- cgit