gofiber_html

package module
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2025 License: MIT Imports: 8 Imported by: 0

README

gofiber-html

gofiber-html uses the Go builtin html/template as Fiber template engine. Here's the original syntax of html/template

Check the sample app in example/ directory to get start.

Notes

About the html module offered by gofiber/template repo:

  • it can not specify web page title in template files.

    If you define a template to hold page title like {{template "title" .}} in layout file, then define page title like {{define "title"}}...{{end}} in each template file, only the one in last parsed template file will be kept and used (earlies ones are overwrote), this is not ideal for i18n.

  • it doesn't expose funcmap.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine struct

func New

func New(directory, extension string) *Engine

New returns a HTML render engine for Fiber

func NewFileSystem

func NewFileSystem(fs fs.FS, extension string) *Engine

NewFileSystem ...

func (*Engine) AddFunc

func (e *Engine) AddFunc(name string, fn interface{}) *Engine

AddFunc adds the function to the template's function map. It is legal to overwrite elements of the default actions

func (*Engine) AddFuncMap

func (e *Engine) AddFuncMap(m map[string]interface{}) *Engine

AddFuncMap adds the functions from a map to the template's function map. It is legal to overwrite elements of the default actions

func (*Engine) AddLayouts

func (e *Engine) AddLayouts(layouts ...string) *Engine

func (*Engine) Debug

func (e *Engine) Debug(enabled bool) *Engine

Debug will print the parsed templates when Load is triggered.

func (*Engine) Delims

func (e *Engine) Delims(left, right string) *Engine

Delims sets the action delimiters to the specified strings, to be used in templates. An empty delimiter stands for the corresponding default: {{ or }}.

func (*Engine) FuncMap

func (e *Engine) FuncMap() map[string]any

func (*Engine) Load

func (e *Engine) Load() error

Load satisfies Fiber's `Template` interface.

func (*Engine) Render

func (e *Engine) Render(out io.Writer, template string, binding interface{}, layout ...string) error

Render will execute the template name along with the given values.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL