Documentation
¶
Index ¶
- type DynamicRender
- func (r DynamicRender) Add(name string, tmpl *template.Template)
- func (r DynamicRender) AddFromFS(name string, fsys fs.FS, files ...string) *template.Template
- func (r DynamicRender) AddFromFSFuncs(name string, funcMap template.FuncMap, fsys fs.FS, files ...string) *template.Template
- func (r DynamicRender) AddFromFiles(name string, files ...string) *template.Template
- func (r DynamicRender) AddFromFilesFuncs(name string, funcMap template.FuncMap, files ...string) *template.Template
- func (r DynamicRender) AddFromFilesFuncsWithOptions(name string, funcMap template.FuncMap, options TemplateOptions, ...) *template.Template
- func (r DynamicRender) AddFromGlob(name, glob string) *template.Template
- func (r DynamicRender) AddFromString(name, templateString string) *template.Template
- func (r DynamicRender) AddFromStringsFuncs(name string, funcMap template.FuncMap, templateStrings ...string) *template.Template
- func (r DynamicRender) AddFromStringsFuncsWithOptions(name string, funcMap template.FuncMap, options TemplateOptions, ...) *template.Template
- func (r DynamicRender) Instance(name string, data interface{}) render.Render
- type Render
- func (r Render) Add(name string, tmpl *template.Template)
- func (r Render) AddFromFS(name string, fsys fs.FS, files ...string) *template.Template
- func (r Render) AddFromFSFuncs(name string, funcMap template.FuncMap, fsys fs.FS, files ...string) *template.Template
- func (r Render) AddFromFiles(name string, files ...string) *template.Template
- func (r Render) AddFromFilesFuncs(name string, funcMap template.FuncMap, files ...string) *template.Template
- func (r Render) AddFromFilesFuncsWithOptions(name string, funcMap template.FuncMap, options TemplateOptions, ...) *template.Template
- func (r Render) AddFromGlob(name, glob string) *template.Template
- func (r Render) AddFromString(name, templateString string) *template.Template
- func (r Render) AddFromStringsFuncs(name string, funcMap template.FuncMap, templateStrings ...string) *template.Template
- func (r Render) AddFromStringsFuncsWithOptions(name string, funcMap template.FuncMap, options TemplateOptions, ...) *template.Template
- func (r Render) Instance(name string, data interface{}) render.Render
- type Renderer
- type TemplateOption
- type TemplateOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DynamicRender ¶
type DynamicRender map[string]*templateBuilder
DynamicRender type
func NewDynamic ¶
func NewDynamic() DynamicRender
NewDynamic is the constructor for Dynamic templates
func (DynamicRender) Add ¶
func (r DynamicRender) Add(name string, tmpl *template.Template)
Add new template
func (DynamicRender) AddFromFS ¶
AddFromFS adds a new template to the DynamicRender from the provided file system (fs.FS) and files. It allows you to specify a custom function map (funcMap) to be used within the template. The name parameter is used to associate the template with a key in the DynamicRender. The files parameter is a variadic list of file paths to be included in the template.
- name: The name to associate with the template in the DynamicRender.
- fsys: The file system (fs.FS) from which to read the template files.
- files: A variadic list of file paths to be included in the template.
Returns:
- *template.Template: The constructed template.
func (DynamicRender) AddFromFSFuncs ¶ added in v1.0.2
func (r DynamicRender) AddFromFSFuncs( name string, funcMap template.FuncMap, fsys fs.FS, files ...string, ) *template.Template
AddFromFSFuncs adds a new template to the DynamicRender from the provided file system (fs.FS) and files. It allows you to specify a custom function map (funcMap) to be used within the template.
Parameters:
- name: The name to associate with the template in the DynamicRender.
- funcMap: A map of functions to be used within the template.
- fsys: The file system (fs.FS) from which to read the template files.
- files: A variadic list of file paths to be included in the template.
Returns:
- *template.Template: The constructed template.
func (DynamicRender) AddFromFiles ¶
func (r DynamicRender) AddFromFiles(name string, files ...string) *template.Template
AddFromFiles supply add template from files
func (DynamicRender) AddFromFilesFuncs ¶
func (r DynamicRender) AddFromFilesFuncs(name string, funcMap template.FuncMap, files ...string) *template.Template
AddFromFilesFuncs supply add template from file callback func
func (DynamicRender) AddFromFilesFuncsWithOptions ¶ added in v1.1.0
func (r DynamicRender) AddFromFilesFuncsWithOptions( name string, funcMap template.FuncMap, options TemplateOptions, files ...string, ) *template.Template
AddFromFilesFuncs supply add template from file callback func
func (DynamicRender) AddFromGlob ¶
func (r DynamicRender) AddFromGlob(name, glob string) *template.Template
AddFromGlob supply add template from global path
func (DynamicRender) AddFromString ¶
func (r DynamicRender) AddFromString(name, templateString string) *template.Template
AddFromString supply add template from strings
func (DynamicRender) AddFromStringsFuncs ¶
func (r DynamicRender) AddFromStringsFuncs( name string, funcMap template.FuncMap, templateStrings ...string, ) *template.Template
AddFromStringsFuncs supply add template from strings
func (DynamicRender) AddFromStringsFuncsWithOptions ¶ added in v1.1.0
func (r DynamicRender) AddFromStringsFuncsWithOptions( name string, funcMap template.FuncMap, options TemplateOptions, templateStrings ...string, ) *template.Template
AddFromStringsFuncsWithOptions supply add template from strings with options
type Render ¶
Render type
func (Render) AddFromFSFuncs ¶ added in v1.0.2
func (r Render) AddFromFSFuncs(name string, funcMap template.FuncMap, fsys fs.FS, files ...string) *template.Template
AddFromFSFuncs supply add template from fs.FS (e.g. embed.FS) with callback func
func (Render) AddFromFiles ¶
AddFromFiles supply add template from files
func (Render) AddFromFilesFuncs ¶
func (r Render) AddFromFilesFuncs(name string, funcMap template.FuncMap, files ...string) *template.Template
AddFromFilesFuncs supply add template from file callback func
func (Render) AddFromFilesFuncsWithOptions ¶ added in v1.1.0
func (r Render) AddFromFilesFuncsWithOptions( name string, funcMap template.FuncMap, options TemplateOptions, files ...string, ) *template.Template
AddFromFilesFuncsWithOptions supply add template from file callback func with options
func (Render) AddFromGlob ¶
AddFromGlob supply add template from global path
func (Render) AddFromString ¶
AddFromString supply add template from strings
func (Render) AddFromStringsFuncs ¶
func (r Render) AddFromStringsFuncs( name string, funcMap template.FuncMap, templateStrings ...string, ) *template.Template
AddFromStringsFuncs supply add template from strings
func (Render) AddFromStringsFuncsWithOptions ¶ added in v1.1.0
func (r Render) AddFromStringsFuncsWithOptions( name string, funcMap template.FuncMap, options TemplateOptions, templateStrings ...string, ) *template.Template
AddFromStringsFuncsWithOptions supply add template from strings with options
type Renderer ¶
type Renderer interface { render.HTMLRender Add(name string, tmpl *template.Template) AddFromFiles(name string, files ...string) *template.Template AddFromGlob(name, glob string) *template.Template AddFromFS(name string, fsys fs.FS, files ...string) *template.Template AddFromFSFuncs(name string, funcMap template.FuncMap, fsys fs.FS, files ...string) *template.Template AddFromString(name, templateString string) *template.Template AddFromStringsFuncs(name string, funcMap template.FuncMap, templateStrings ...string) *template.Template AddFromStringsFuncsWithOptions( name string, funcMap template.FuncMap, options TemplateOptions, templateStrings ...string, ) *template.Template AddFromFilesFuncs(name string, funcMap template.FuncMap, files ...string) *template.Template AddFromFilesFuncsWithOptions( name string, funcMap template.FuncMap, options TemplateOptions, files ...string, ) *template.Template }
Renderer type is the Agnostic Renderer for multitemplates. When gin is in debug mode then all multitemplates works with hot reloading allowing you modify file templates and seeing changes instantly. Renderer should be created using multitemplate.NewRenderer() constructor.
func NewRenderer ¶
func NewRenderer() Renderer
NewRenderer allows create an agnostic multitemplate renderer depending on enabled gin mode
type TemplateOption ¶ added in v1.1.0
type TemplateOption func(*TemplateOptions)
func Delims ¶ added in v1.1.0
func Delims(leftDelim, rightDelim string) TemplateOption
func WithLeftDelimiter ¶ added in v1.1.0
func WithLeftDelimiter(delim string) TemplateOption
func WithRightDelimiter ¶ added in v1.1.0
func WithRightDelimiter(delim string) TemplateOption
type TemplateOptions ¶ added in v1.1.0
Render type
func NewTemplateOptions ¶ added in v1.1.0
func NewTemplateOptions(opts ...TemplateOption) *TemplateOptions