Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
30ab8cf7
Commit
30ab8cf7
authored
Aug 16, 2010
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
template: retain leading space if the line is not an action.
R=rsc CC=golang-dev
https://golang.org/cl/1985042
parent
316961c1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
3 deletions
+5
-3
template.go
src/pkg/template/template.go
+4
-3
template_test.go
src/pkg/template/template_test.go
+1
-0
No files found.
src/pkg/template/template.go
View file @
30ab8cf7
...
...
@@ -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'
{
...
...
src/pkg/template/template_test.go
View file @
30ab8cf7
...
...
@@ -98,6 +98,7 @@ var tests = []*Test{
&
Test
{
" {.space}
\n
"
,
" "
,
""
},
&
Test
{
" {.tab}
\n
"
,
"
\t
"
,
""
},
&
Test
{
" {#comment}
\n
"
,
""
,
""
},
&
Test
{
"
\t
Some Text
\t\n
"
,
"
\t
Some Text
\t\n
"
,
""
},
// Variables at top level
&
Test
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment