package template
import "github.com/nicksnyder/go-i18n/v2/i18n/template"
Package template defines a generic interface for template parsers and implementations of that interface.
Index ¶
- type IdentityParser
- func (IdentityParser) Cacheable() bool
- func (IdentityParser) Parse(src, leftDelim, rightDelim string) (ParsedTemplate, error)
- type ParsedTemplate
- type Parser
- type TextParser
Types ¶
type IdentityParser ¶
type IdentityParser struct{}
IdentityParser is an Parser that does no parsing and returns template string unchanged.
func (IdentityParser) Cacheable ¶
func (IdentityParser) Cacheable() bool
func (IdentityParser) Parse ¶
func (IdentityParser) Parse(src, leftDelim, rightDelim string) (ParsedTemplate, error)
type ParsedTemplate ¶
type ParsedTemplate interface {
// Execute applies a parsed template to the specified data.
Execute(data any) (string, error)
}
ParsedTemplate is an executable template.
type Parser ¶
type Parser interface {
// Parse parses src and returns a ParsedTemplate.
Parse(src, leftDelim, rightDelim string) (ParsedTemplate, error)
// Cacheable returns true if Parse returns ParsedTemplates that are always safe to cache.
Cacheable() bool
}
Parser parses strings into executable templates.
type TextParser ¶
TextParser is a Parser that uses text/template.
func (*TextParser) Cacheable ¶
func (te *TextParser) Cacheable() bool
func (*TextParser) Parse ¶
func (te *TextParser) Parse(src, leftDelim, rightDelim string) (ParsedTemplate, error)
Source Files ¶
identity_parser.go parser.go text_parser.go
- Version
- v2.6.0 (latest)
- Published
- Apr 5, 2025
- Platform
- linux/amd64
- Imports
- 3 packages
- Last checked
- 1 year ago –
Tools for package owners.