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

Method emitComment

parser/parser.go:118–148  ·  view source on GitHub ↗
(comment []byte)

Source from the content-addressed store, hash-verified

116}
117
118func (p *parser) emitComment(comment []byte) {
119 isFirstNonemptyLine := false
120 for len(comment) > 0 {
121 n := bytes.IndexByte(comment, '\n')
122 if n < 0 {
123 n = len(comment)
124 }
125 line := stripTrailingSpace(comment[:n])
126 if bytes.HasPrefix(line, []byte("//")) {
127 line = line[2:]
128 if len(line) > 0 && isSpace(line[0]) {
129 line = line[1:]
130 }
131 }
132 if len(line) == 0 {
133 if isFirstNonemptyLine {
134 fmt.Fprintf(p.w, "//\n")
135 }
136 } else {
137 fmt.Fprintf(p.w, "// %s\n", line)
138 isFirstNonemptyLine = true
139 }
140
141 if n < len(comment) {
142 comment = comment[n+1:]
143 } else {
144 comment = comment[n:]
145 }
146 }
147 fmt.Fprintf(p.w, "\n")
148}
149
150func (p *parser) emitImportsUse() {
151 if p.importsUseEmitted {

Callers 2

parseTemplateMethod · 0.95
parseSwitchMethod · 0.95

Calls 2

stripTrailingSpaceFunction · 0.85
isSpaceFunction · 0.85

Tested by

no test coverage detected