MCPcopy
hub / github.com/valyala/quicktemplate / Next

Method Next

parser/scanner.go:97–182  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

95}
96
97func (s *scanner) Next() bool {
98 if s.rewind {
99 s.rewind = false
100 return true
101 }
102
103 for {
104 if !s.scanToken() {
105 return false
106 }
107 switch s.t.ID {
108 case text:
109 if s.stripToNewLine {
110 s.t.Value = tailOfLine.ReplaceAll(s.t.Value, nil)
111 s.stripToNewLine = false
112 }
113 if len(s.t.Value) == 0 {
114 // skip empty text
115 continue
116 }
117 case tagName:
118 switch string(s.t.Value) {
119 case "comment":
120 if !s.skipComment() {
121 return false
122 }
123 continue
124 case "plain":
125 if !s.readPlain() {
126 return false
127 }
128 if len(s.t.Value) == 0 {
129 // skip empty text
130 continue
131 }
132 case "collapsespace":
133 if !s.readTagContents() {
134 return false
135 }
136 s.collapseSpaceDepth++
137 continue
138 case "stripspace":
139 if !s.readTagContents() {
140 return false
141 }
142 s.stripSpaceDepth++
143 continue
144 case "endcollapsespace":
145 if s.collapseSpaceDepth == 0 {
146 s.err = fmt.Errorf("endcollapsespace tag found without the corresponding collapsespace tag")
147 return false
148 }
149 if !s.readTagContents() {
150 return false
151 }
152 s.collapseSpaceDepth--
153 continue
154 case "endstripspace":

Callers 15

BenchmarkQWriterVStringFunction · 0.80
BenchmarkQWriterVIntFunction · 0.80
benchmarkQWriterQFunction · 0.80
benchmarkQWriterJFunction · 0.80
benchmarkQWriterUFunction · 0.80
BenchmarkQWriterFfloatFunction · 0.80
BenchmarkQWriterFintFunction · 0.80
BenchmarkQWriterDFunction · 0.80
benchmarkQWriterZFunction · 0.80

Calls 5

scanTokenMethod · 0.95
skipCommentMethod · 0.95
readPlainMethod · 0.95
readTagContentsMethod · 0.95
initMethod · 0.80

Tested by 15

BenchmarkQWriterVStringFunction · 0.64
BenchmarkQWriterVIntFunction · 0.64
benchmarkQWriterQFunction · 0.64
benchmarkQWriterJFunction · 0.64
benchmarkQWriterUFunction · 0.64
BenchmarkQWriterFfloatFunction · 0.64
BenchmarkQWriterFintFunction · 0.64
BenchmarkQWriterDFunction · 0.64
benchmarkQWriterZFunction · 0.64