| 204 | } |
| 205 | |
| 206 | func (s *Set) parse(name, text string, cacheAfterParsing bool) (t *Template, err error) { |
| 207 | t = &Template{ |
| 208 | Name: name, |
| 209 | ParseName: name, |
| 210 | text: text, |
| 211 | set: s, |
| 212 | passedBlocks: make(map[string]*BlockNode), |
| 213 | } |
| 214 | defer t.recover(&err) |
| 215 | |
| 216 | lexer := lex(name, text, false) |
| 217 | lexer.setDelimiters(s.leftDelim, s.rightDelim) |
| 218 | lexer.setCommentDelimiters(s.leftComment, s.rightComment) |
| 219 | lexer.run() |
| 220 | t.startParse(lexer) |
| 221 | t.parseTemplate(cacheAfterParsing) |
| 222 | t.stopParse() |
| 223 | |
| 224 | if t.extends != nil { |
| 225 | t.addBlocks(t.extends.processedBlocks) |
| 226 | } |
| 227 | |
| 228 | for _, _import := range t.imports { |
| 229 | t.addBlocks(_import.processedBlocks) |
| 230 | } |
| 231 | |
| 232 | t.addBlocks(t.passedBlocks) |
| 233 | |
| 234 | return t, err |
| 235 | } |
| 236 | |
| 237 | func (t *Template) expectString(context string) string { |
| 238 | token := t.expectOneOf(itemString, itemRawString, context, "string literal") |