Documentation ¶
Index ¶
- Variables
- func Compile(path, base string) error
- func CompileDir(dir string) error
- func Execute(tplName string, w io.Writer, data interface{}) error
- func Register(ext string, c TemplateCompiler)
- func Render(tplName string, w http.ResponseWriter, data interface{}) (err error)
- type TemplateCompiler
- type Templater
Constants ¶
This section is empty.
Variables ¶
var ( ErrTemplateNotExist = errors.New("template does not exist") ErrDirNotExist = errors.New("directory does not exist") )
Functions ¶
func Compile ¶
Compile a single template file, using the specified base directory. The base directory is used to set the name of the template (the part of the path relative to this base directory is used as the name of the template).
func CompileDir ¶
Compile all templates that have a matching compiler (based on their extension) in the specified directory.
func Register ¶
func Register(ext string, c TemplateCompiler)
Register a template compiler for the specified extension. Extensions are case-sensitive. The extension must start with a dot (it is compared to the result of path.Ext() on a given file name).
Registering is not thread-safe. Compilers should be registered before the http server is started. Compiling templates, on the other hand, is thread-safe.
Types ¶
type TemplateCompiler ¶
The interface that a template engine must implement to be used by Ghost.