Documentation ¶
Index ¶
- Constants
- Variables
- func Must(tpl *exec.Template, err error) *exec.Template
- type Config
- type Context
- type Environment
- func (env *Environment) CleanCache(filenames ...string)
- func (env *Environment) FromBytes(tpl []byte) (*exec.Template, error)
- func (env *Environment) FromCache(filename string) (*exec.Template, error)
- func (env *Environment) FromFile(filename string) (*exec.Template, error)
- func (env *Environment) FromString(tpl string) (*exec.Template, error)
- func (env *Environment) GetTemplate(filename string) (*exec.Template, error)
- func (env *Environment) Path(path string) (string, error)
Constants ¶
const VERSION = "1.5.3"
Variables ¶
var ( // DefaultLoader is being used by the DefaultSet. DefaultLoader = loaders.MustNewFileSystemLoader("") // DefaultEnv is an environment created for quick/standalone template rendering. DefaultEnv = NewEnvironment(config.DefaultConfig, DefaultLoader) // Methods on the default set FromString = DefaultEnv.FromString FromBytes = DefaultEnv.FromBytes FromFile = DefaultEnv.FromFile FromCache = DefaultEnv.FromCache // Globals for the default set Globals = DefaultEnv.Globals )
var NewConfig = config.NewConfig
Functions ¶
Types ¶
type Environment ¶
type Environment struct { *exec.EvalConfig Loader loaders.Loader Cache map[string]*exec.Template CacheMutex sync.Mutex }
func NewEnvironment ¶
func NewEnvironment(cfg *config.Config, loader loaders.Loader) *Environment
func (*Environment) CleanCache ¶
func (env *Environment) CleanCache(filenames ...string)
CleanCache cleans the template cache. If filenames is not empty, it will remove the template caches of those filenames. Or it will empty the whole template cache. It is thread-safe.
func (*Environment) FromBytes ¶
func (env *Environment) FromBytes(tpl []byte) (*exec.Template, error)
FromBytes loads a template from bytes and returns a Template instance.
func (*Environment) FromCache ¶
func (env *Environment) FromCache(filename string) (*exec.Template, error)
FromCache is a convenient method to cache templates. It is thread-safe and will only compile the template associated with a filename once. If Environment.Debug is true (for example during development phase), FromCache() will not cache the template and instead recompile it on any call (to make changes to a template live instantaneously).
func (*Environment) FromFile ¶
func (env *Environment) FromFile(filename string) (*exec.Template, error)
FromFile loads a template from a filename and returns a Template instance.
func (*Environment) FromString ¶
func (env *Environment) FromString(tpl string) (*exec.Template, error)
FromString loads a template from string and returns a Template instance.
func (*Environment) GetTemplate ¶
func (env *Environment) GetTemplate(filename string) (*exec.Template, error)