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
cf8b9ce5
Commit
cf8b9ce5
authored
Apr 15, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test & fix template used twice
R=r DELTA=30 (30 added, 0 deleted, 0 changed) OCL=27470 CL=27474
parent
fa602260
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
template.go
src/lib/template/template.go
+1
-0
template_test.go
src/lib/template/template_test.go
+29
-0
No files found.
src/lib/template/template.go
View file @
cf8b9ce5
...
...
@@ -514,6 +514,7 @@ func (t *Template) Execute(data interface{}, wr io.Write) *os.Error {
val
:=
reflect
.
NewValue
(
data
);
ch
:=
make
(
chan
*
os
.
Error
);
go
func
()
{
t
.
p
=
0
;
t
.
execute
(
&
state
{
nil
,
ch
,
val
,
wr
});
ch
<-
nil
;
// clean return;
}();
...
...
src/lib/template/template_test.go
View file @
cf8b9ce5
...
...
@@ -199,8 +199,37 @@ func TestStringDriverType(t *testing.T) {
}
var
b
io
.
ByteBuffer
;
err
=
tmpl
.
Execute
(
"hello"
,
&
b
);
if
err
!=
nil
{
t
.
Error
(
"unexpected parse error:"
,
err
)
}
s
:=
string
(
b
.
Data
());
if
s
!=
"template: hello"
{
t
.
Errorf
(
"failed passing string as data: expected %q got %q"
,
"template: hello"
,
s
)
}
}
func
TestTwice
(
t
*
testing
.
T
)
{
tmpl
,
err
,
line
:=
Parse
(
"template: {@}"
,
nil
);
if
err
!=
nil
{
t
.
Error
(
"unexpected parse error:"
,
err
)
}
var
b
io
.
ByteBuffer
;
err
=
tmpl
.
Execute
(
"hello"
,
&
b
);
if
err
!=
nil
{
t
.
Error
(
"unexpected parse error:"
,
err
)
}
s
:=
string
(
b
.
Data
());
text
:=
"template: hello"
;
if
s
!=
text
{
t
.
Errorf
(
"failed passing string as data: expected %q got %q"
,
text
,
s
);
}
err
=
tmpl
.
Execute
(
"hello"
,
&
b
);
if
err
!=
nil
{
t
.
Error
(
"unexpected parse error:"
,
err
)
}
s
=
string
(
b
.
Data
());
text
+=
text
;
if
s
!=
text
{
t
.
Errorf
(
"failed passing string as data: expected %q got %q"
,
text
,
s
);
}
}
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