| 1 |
// Package template defines a generic interface for template parsers and implementations of that interface. |
| 2 |
package template |
| 3 |
|
| 4 |
// Parser parses strings into executable templates. |
| 5 |
type Parser interface { |
| 6 |
// Parse parses src and returns a ParsedTemplate. |
| 7 |
Parse(src, leftDelim, rightDelim string) (ParsedTemplate, error) |
| 8 |
|
| 9 |
// Cacheable returns true if Parse returns ParsedTemplates that are always safe to cache. |
| 10 |
Cacheable() bool |
| 11 |
} |
| 12 |
|
| 13 |
// ParsedTemplate is an executable template. |
| 14 |
type ParsedTemplate interface { |
| 15 |
// Execute applies a parsed template to the specified data. |
| 16 |
Execute(data any) (string, error) |
| 17 |
} |