}
t.backup2(delim)
}
- n := t.textOrAction()
- if n.Type() == nodeEnd {
+ switch n := t.textOrAction(); n.Type() {
+ case nodeEnd, nodeElse:
t.errorf("unexpected %s", n)
+ default:
+ t.Root.append(n)
}
- t.Root.append(n)
}
return nil
}
// Errors.
{"unclosed action", "hello{{range", hasError, ""},
{"unmatched end", "{{end}}", hasError, ""},
+ {"unmatched else", "{{else}}", hasError, ""},
+ {"unmatched else after if", "{{if .X}}hello{{end}}{{else}}", hasError, ""},
+ {"multiple else", "{{if .X}}1{{else}}2{{else}}3{{end}}", hasError, ""},
{"missing end", "hello{{range .x}}", hasError, ""},
{"missing end after else", "hello{{range .x}}{{else}}", hasError, ""},
{"undefined function", "hello{{undefined}}", hasError, ""},