| 1 |
package template |
| 2 |
|
| 3 |
// IdentityParser is an Parser that does no parsing and returns template string unchanged. |
| 4 |
type IdentityParser struct{} |
| 5 |
|
| 6 |
func (IdentityParser) Cacheable() bool { |
| 7 |
// Caching is not necessary because Parse is cheap. |
| 8 |
return false |
| 9 |
} |
| 10 |
|
| 11 |
func (IdentityParser) Parse(src, leftDelim, rightDelim string) (ParsedTemplate, error) { |
| 12 |
return &identityParsedTemplate{src: src}, nil |
| 13 |
} |
| 14 |
|
| 15 |
type identityParsedTemplate struct { |
| 16 |
src string |
| 17 |
} |
| 18 |
|
| 19 |
func (t *identityParsedTemplate) Execute(data any) (string, error) { |
| 20 |
return t.src, nil |
| 21 |
} |