Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1196)

Side by Side Diff: src/pkg/text/template/exec.go

Issue 5449071: code review 5449071: various: shorten composite literal field values (Closed)
Patch Set: diff -r f91f50b96e10 https://go.googlecode.com/hg/ Created 12 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« src/pkg/testing/benchmark.go ('K') | « src/pkg/testing/benchmark.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Go Authors. All rights reserved. 1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package template 5 package template
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "io" 9 "io"
10 "reflect" 10 "reflect"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 // Execute applies a parsed template to the specified data object, 98 // Execute applies a parsed template to the specified data object,
99 // and writes the output to wr. 99 // and writes the output to wr.
100 func (t *Template) Execute(wr io.Writer, data interface{}) (err error) { 100 func (t *Template) Execute(wr io.Writer, data interface{}) (err error) {
101 defer errRecover(&err) 101 defer errRecover(&err)
102 value := reflect.ValueOf(data) 102 value := reflect.ValueOf(data)
103 state := &state{ 103 state := &state{
104 tmpl: t, 104 tmpl: t,
105 wr: wr, 105 wr: wr,
106 line: 1, 106 line: 1,
107 » » vars: []variable{{"$", value}}, 107 » » vars: {{"$", value}},
gri 2011/12/02 23:04:18 unreadable
108 } 108 }
109 if t.Tree == nil || t.Root == nil { 109 if t.Tree == nil || t.Root == nil {
110 state.errorf("must be parsed before execution") 110 state.errorf("must be parsed before execution")
111 } 111 }
112 state.walk(value, t.Root) 112 state.walk(value, t.Root)
113 return 113 return
114 } 114 }
115 115
116 // Walk functions step through the major pieces of the template structure, 116 // Walk functions step through the major pieces of the template structure,
117 // generating output as they go. 117 // generating output as they go.
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 v = v.Addr() 659 v = v.Addr()
660 } else { 660 } else {
661 switch v.Kind() { 661 switch v.Kind() {
662 case reflect.Chan, reflect.Func: 662 case reflect.Chan, reflect.Func:
663 s.errorf("can't print %s of type %s", n, v.Type( )) 663 s.errorf("can't print %s of type %s", n, v.Type( ))
664 } 664 }
665 } 665 }
666 } 666 }
667 fmt.Fprint(s.wr, v.Interface()) 667 fmt.Fprint(s.wr, v.Interface())
668 } 668 }
OLDNEW
« src/pkg/testing/benchmark.go ('K') | « src/pkg/testing/benchmark.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b