Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( //ErrTemplateNotExist returned when not template is not found //in the map of templates ErrTemplateNotExist = errors.New("template not found") )
Functions ¶
This section is empty.
Types ¶
type Template ¶
type Template struct { //content template directory //define the templates here and use //them in the layout template ContentDir string //layout template directory //content templates that are used //in the layout template must be defined //in the content template LayoutDir string //file name extension of template files Ext string //set to true to enable hot reload HotReload bool // contains filtered or unexported fields }
Template wraps the html/template to add functionality
func NewBasic ¶
func NewBasic() Template
NewBasic returns a new empty Template if you use this, you have to manually add the ContentDir (required) and LayoutDir and Ext which are both optional
func (*Template) Init ¶
Init performs the initialization contentDir: is the directory of content templates layoutDir: is the directory of layout templates ext: is for file extension (e.g. .html, .txt etc.) .html is used if ext is empty Note: if you even forgot to call Init, it will be called when you call Execute But it is strongly suggested that you initialize it before everything else since so that it can be verified if the template files exists
type Templates ¶
type Templates struct { //set to true if you want all the //tempaltes contained in here to enable hot reload HotReload bool // contains filtered or unexported fields }
Templates is a map of plet.Template
func NewTemplates ¶
func NewTemplates() *Templates
NewTemplates returns a new Templates which actually is just a map of Template
func (*Templates) Add ¶
Add adds a template to the template map if template is previously added, it will be overwritten