Fix .alternates execution: it was skipping every second token.

R=r
APPROVED=r
DELTA=13  (11 added, 0 deleted, 2 changed)
OCL=34081
CL=34081
This commit is contained in:
David Symonds 2009-08-29 21:13:32 -07:00
parent bc15b94181
commit 792eba220e
2 changed files with 13 additions and 2 deletions

View File

@ -738,7 +738,7 @@ func (t *Template) executeRepeated(r *repeatedElement, st *state) {
// .alternates between elements
if !first && r.altstart >= 0 {
for i := r.altstart; i < r.altend; i++ {
for i := r.altstart; i < r.altend; {
i = t.executeElement(i, newst)
}
}
@ -758,7 +758,7 @@ func (t *Template) executeRepeated(r *repeatedElement, st *state) {
// .alternates between elements
if !first && r.altstart >= 0 {
for i := r.altstart; i < r.altend; i++ {
for i := r.altstart; i < r.altend; {
i = t.executeElement(i, newst)
}
}

View File

@ -187,6 +187,17 @@ var tests = []*Test {
out: "this should appear: empty field\n"
},
&Test{
in: "{.repeated section pdata }\n"
"{item}\n"
"{.alternates with}\n"
"is\nover\nmultiple\nlines\n"
"{.end}\n",
out: "ItemNumber1\n"
"is\nover\nmultiple\nlines\n"
"ItemNumber2\n"
},
&Test{
in: "{.section pdata }\n"
"{.repeated section @ }\n"