Documentation ¶
Index ¶
- Constants
- func DefaultFileHandler() fileHandler
- type Execute
- func (e *Execute) Config() tpl.TemplateConfig
- func (e *Execute) Execute(w io.Writer, name string, data interface{}) (string, error)
- func (e *Execute) ExecutePost(w io.Writer, name string, ctx *gin.Context, post *domain.PostDatum) (string, error)
- func (e *Execute) Executor() tpl.TemplateExecutor
- func (e *Execute) Exists(name string) bool
- type TemplateManager
- func (t *TemplateManager) Data(ctx *gin.Context, post *domain.PostDatum) interface{}
- func (t *TemplateManager) ExecuteTpl(w io.Writer, text string, data interface{}) error
- func (t *TemplateManager) FuncMap(ctx *gin.Context, post *domain.PostDatum, cfg tpl.TemplateConfig) template.FuncMap
- func (t *TemplateManager) GenericFuncMap() template.FuncMap
- func (t *TemplateManager) Prepare(c tpl.TemplateConfig) tpl.TemplateExecutor
Constants ¶
const ( // DelimitersLeft left for the template. DelimitersLeft = "{{" // DelimitersRight right for the template. DelimitersRight = "}}" )
Variables ¶
This section is empty.
Functions ¶
func DefaultFileHandler ¶
func DefaultFileHandler() fileHandler
DefaultFileHandler
Accepts a template path and looks up the page template by the template path and file extension set in the engine.
Returns errors.TEMPLATE if thee file does not exist or filepath.Abs failed.
Types ¶
type Execute ¶
type Execute struct { *TemplateManager // contains filtered or unexported fields }
Execute defines the data for rendering a template contains.
func (*Execute) Config ¶
func (e *Execute) Config() tpl.TemplateConfig
Config
Satisfies the tpl.TemplateExecutor interface by returning the Execute configuration to obtain the root, extension and master layout.
func (*Execute) Execute ¶
Execute
Satisfies the tpl.TemplateExecutor interface by executing a template with a io.Writer, the name of the template and any data to be passed. As this function is not attached to any context, the generic function map is used.
func (*Execute) ExecutePost ¶
func (e *Execute) ExecutePost(w io.Writer, name string, ctx *gin.Context, post *domain.PostDatum) (string, error)
ExecutePost
Satisfies the tpl.TemplateExecutor interface by executing a template with a io.Writer, the name of the template the context and the domain.PostDatum. Data is not needed to be passed as data is obtained from the variables package.
func (*Execute) Executor ¶
func (e *Execute) Executor() tpl.TemplateExecutor
Executor
Satisfies the tpl.TemplateExecutor interface by returning itself for use with recovery
type TemplateManager ¶
type TemplateManager struct {
// contains filtered or unexported fields
}
TemplateManager defines the service for executing and parsing Verbis templates. It's responsible for obtaining a template.FuncMap and Data to be used within the template.
func (*TemplateManager) Data ¶
func (t *TemplateManager) Data(ctx *gin.Context, post *domain.PostDatum) interface{}
Data
Satisfies the tpl.TemplateDataGetter interface by returning data for the front end that relies on context and post data.
func (*TemplateManager) ExecuteTpl ¶
func (t *TemplateManager) ExecuteTpl(w io.Writer, text string, data interface{}) error
ExecuteTpl
Is a helper function for executing standard templates that are embedded.
func (*TemplateManager) FuncMap ¶
func (t *TemplateManager) FuncMap(ctx *gin.Context, post *domain.PostDatum, cfg tpl.TemplateConfig) template.FuncMap
FuncMap
Satisfies the tpl.TemplateFuncGetter interface by returning functions that relies on context and post data such as `Meta` and `url`. Generic functions are also included.
func (*TemplateManager) GenericFuncMap ¶
func (t *TemplateManager) GenericFuncMap() template.FuncMap
GenericFuncMap
Satisfies the tpl.TemplateFuncGetter interface by returning functions that do not rely on any data that is processed at runtime. These functions are loaded on initialisation and stored in memory.
func (*TemplateManager) Prepare ¶
func (t *TemplateManager) Prepare(c tpl.TemplateConfig) tpl.TemplateExecutor
Prepare
Satisfies the tpl.TemplateHandler interface by accepting a tpl.Config data and set's up the template so it's ready for execution.