Documentation
¶
Overview ¶
Package render provides interface to render multiple templates with Gin
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type R ¶
type R struct {
// contains filtered or unexported fields
}
R is the registry of renders.
func New ¶
func New() *R
New returns an instance a new registry of template. It will index all HTML templates to render.
Example ¶
package main
import (
"html/template"
"github.com/gin-gonic/gin"
"github.com/rvflash/safe/cmd/ui/render"
)
type mr struct{}
func (r mr) PageName() string {
return "test"
}
func (r mr) TmplFiles() []string {
return []string{"testdata/tpl.html"}
}
func (r mr) FuncMap() template.FuncMap {
return nil
}
func main() {
gin.SetMode(gin.TestMode)
gs := gin.New()
rs := render.New()
rs.Add(&mr{})
gs.HTMLRender = rs.HTMLRender()
}
func (*R) HTMLRender ¶
func (r *R) HTMLRender() multitemplate.Render
HTMLRender returns a HTML render as expected by Gin.
type Render ¶
type Render interface {
// PageName returns the name of the page.
PageName() string
// TmplFiles returns the paths to the template file(s) of this page.
TmplFiles() []string
// FuncMap returns the custom template functions to use.
FuncMap() template.FuncMap
}
Render must be implemented by any handler to render multiple templates.
Click to show internal directories.
Click to hide internal directories.