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
19692bee
Commit
19692bee
authored
Apr 15, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
treat "" as empty
R=r DELTA=10 (10 added, 0 deleted, 0 changed) OCL=27479 CL=27481
parent
816f5b31
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
2 deletions
+12
-2
template.go
src/lib/template/template.go
+2
-0
template_test.go
src/lib/template/template_test.go
+10
-2
No files found.
src/lib/template/template.go
View file @
19692bee
...
...
@@ -308,6 +308,8 @@ func empty(v reflect.Value, indirect_ok bool) bool {
return
true
}
switch
v
.
Type
()
.
Kind
()
{
case
reflect
.
StringKind
:
return
v
.
(
reflect
.
StringValue
)
.
Get
()
==
""
;
case
reflect
.
StructKind
:
return
false
;
case
reflect
.
ArrayKind
:
...
...
src/lib/template/template_test.go
View file @
19692bee
...
...
@@ -29,6 +29,7 @@ type S struct {
data
[]
T
;
pdata
[]
*
T
;
empty
[]
*
T
;
emptystring
string
;
null
[]
*
T
;
}
...
...
@@ -162,14 +163,21 @@ var tests = []*Test {
"HEADER=78
\n
"
"Header=77
\n
"
},
&
Test
{
"{raw}
\n
"
"{raw|html}
\n
"
,
"&<>!@ #$%^
\n
"
"&<>!@ #$%^
\n
"
},
&
Test
{
"{.section emptystring}emptystring{.end}
\n
"
"{.section header}header{.end}
\n
"
,
"
\n
header
\n
"
},
}
func
TestAll
(
t
*
testing
.
T
)
{
...
...
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