mirror of
https://github.com/askama-rs/askama.git
synced 2025-09-29 05:51:32 +00:00
Fix operator preference at loop.index
This commit is contained in:
parent
c0f9fe973e
commit
0711e3667b
@ -748,7 +748,7 @@ impl<'a> Generator<'a> {
|
||||
if let Expr::Var(name) = *obj {
|
||||
if name == "loop" {
|
||||
if attr == "index" {
|
||||
buf.write("_loop_index + 1");
|
||||
buf.write("(_loop_index + 1)");
|
||||
return DisplayWrap::Unwrapped;
|
||||
} else if attr == "index0" {
|
||||
buf.write("_loop_index");
|
||||
|
@ -1,3 +1,3 @@
|
||||
{% for s in strings %}
|
||||
{{- loop.index0 }}. {{ s }}{% if !loop.first %}{% else %} (first){% endif %}
|
||||
{{- loop.index0 }}. {{ s }}{{ 2 * loop.index }}{% if !loop.first %}{% else %} (first){% endif %}
|
||||
{% endfor %}
|
||||
|
@ -44,5 +44,5 @@ fn test_precedence_for() {
|
||||
let s = PrecedenceTemplate {
|
||||
strings: vec!["A", "alfa", "1"],
|
||||
};
|
||||
assert_eq!(s.render().unwrap(), "0. A (first)\n1. alfa\n2. 1\n");
|
||||
assert_eq!(s.render().unwrap(), "0. A2 (first)\n1. alfa4\n2. 16\n");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user