Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Base ¶ added in v3.1.2
type Base struct { // The name of the extension. // This is used to uniquely identify the extension. ExtensionName 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 }
Base extension This is the base extension.
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 // 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 ExtensionWithFilename ¶ added in v3.1.2
type ExtensionWithFilename interface { Extension // 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 }
ExtensionWithFilename is an extension that exists of a file. This is an addition to the default extensions, where you can specify your own file as a template.
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 SimpleWithFilename ¶ added in v3.1.2
type SimpleWithFilename struct { Base // The file name for the extension. // This is the name of the template to render. FileName string }
Simple extension struct. This is used to render the extension into the base template. Avoids having to create a new struct for each extension.
func (*SimpleWithFilename) Filename ¶ added in v3.1.2
func (s *SimpleWithFilename) Filename() string
Returns the file name of the extension. This is the name of the template to render. The template will be fetched from a template.Manager.
func (*SimpleWithFilename) Name ¶ added in v3.1.2
func (s *SimpleWithFilename) Name() string
Returns the name of the extension.
type SimpleWithStrings ¶ added in v3.1.1
func (*SimpleWithStrings) Name ¶ added in v3.1.1
func (s *SimpleWithStrings) Name() string
Returns the name of the extension.
type SimpleWithTemplate ¶ added in v3.1.1
func (*SimpleWithTemplate) Name ¶ added in v3.1.1
func (s *SimpleWithTemplate) Name() string
Returns the name of the extension.