Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Block ¶
type Block struct { // The name of the block. // IE: {{define "content"}}, the block name is "content". BlockName string // The value of the block. // IE: {{define "content"}}Hello World{{end}}, the value is "Hello World". Value string }
Block is a block of text that is rendered before or after the template.
type Extension ¶
type Extension interface { // The name of the extension. // This is used to uniquely identify the extension. Name() string // The file name for the extension. // This is the name of the template to render. // The template will be fetched from a template.Manager. Filename() string // Extra data for the extension when it is rendered. View(*request.Request) map[string]any }
Template extensions These are extensions that are rendered into the base template. This is useful, if you want to allow people from other packages to extend base templates of for example; an admin panel.
type ExtensionWithStrings ¶ added in v3.1.0
ExtensionWithStrings is an extension that exists of a string. This is an addition to the default extensions, where you can specify your own string as a template.
type ExtensionWithTemplate ¶ added in v3.1.0
ExtensionWithTemplate is an extension that has a template. This is an addition to the default extensions, where you can specify your own template.
type Options ¶
type Options struct { // BaseManager is the manager for the base template. // It is used to get the base template, and to parse the extension template. BaseManager *templates.Manager // ExtensionManager is the manager for the extension template. ExtensionManager *templates.Manager // TemplateName is the name of the template to use as the base. // This is not the file name, but the name of the template. // IE: {{template "base" .}} TemplateName string // BlockName is the name of the block to render the template into. // IE: {{define "content"}} BlockName string // Called when an error occurs. OnError func(*request.Request, error) // Called before the template is rendered. BeforeRender func(*request.Request, *template.Template) // Custom blocks // These are blocks that are rendered before and after the template. CSS *Block JS *Block }
Default options for the extension view. This is used to render the extension into the base template.
type Simple ¶
type Simple struct { // The name of the extension. // This is used to uniquely identify the extension. ExtensionName string // The file name for the extension. // This is the name of the template to render. FileName string // The callback that is called when the extension is rendered. // This is used to get the template data and the template name. // The template name is the name of the template to render. // This is not the file name, but the name of the template. // IE: {{template "base" .}} Callback func(*request.Request) map[string]any }
Simple extension struct. This is used to render the extension into the base template. Avoids having to create a new struct for each extension.