Commit 30ab8cf7 authored by Rob Pike's avatar Rob Pike

template: retain leading space if the line is not an action.

R=rsc
CC=golang-dev
https://golang.org/cl/1985042
parent 316961c1
......@@ -234,9 +234,7 @@ func (t *Template) nextItem() []byte {
break
}
}
if trimSpace {
start = i
} else if i > start {
if !trimSpace && i > start {
// white space is valid text
t.p = i
return t.buf[start:i]
......@@ -252,6 +250,9 @@ Switch:
i += len(t.ldelim) // position after delimiter
if i+1 < len(t.buf) && (t.buf[i] == '.' || t.buf[i] == '#') {
special = true
if trimSpace {
start = i - len(t.ldelim)
}
}
for ; i < len(t.buf); i++ {
if t.buf[i] == '\n' {
......
......@@ -98,6 +98,7 @@ var tests = []*Test{
&Test{" {.space} \n", " ", ""},
&Test{" {.tab} \n", "\t", ""},
&Test{" {#comment} \n", "", ""},
&Test{"\tSome Text\t\n", "\tSome Text\t\n", ""},
// Variables at top level
&Test{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment