view

package
v2.0.26 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadFile

func ReadFile(path string, fs http.FileSystem) ([]byte, error)

ReadFile returns the raw content of a file

func Walk

func Walk(fs http.FileSystem, root string, walkFn filepath.WalkFunc) error

Walk walks the filesystem rooted at root, calling walkFn for each file or directory in the filesystem, including root. All errors that arise visiting files and directories are filtered by walkFn. The files are walked in lexical order.

Types

type Engine

type Engine struct {
	IEngineView
	http.FileSystem        // http.FileSystem supports embedded files
	Left            string // default {{
	Right           string // default }}
	Directory       string // views folder
	LayoutName      string
	LayoutFunc      string
	Theme           string
	PrefixTheme     string
	UseTheme        bool
	UsePrefixTheme  bool
	Loaded          bool
	Ext             string
	Verbose         bool
	Mutex           sync.RWMutex
	Helpers         map[string]any
	Binding         any
}

func (*Engine) AddFunc

func (e *Engine) AddFunc(name string, fn any)

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]any)

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) Debug

func (e *Engine) Debug(enabled bool)

Debug will print the parsed templates when Load is triggered.

func (*Engine) Delims

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

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

func (*Engine) FuncMap

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

FuncMap returns the template's function map.

func (*Engine) Layout

func (e *Engine) Layout(key string)

Layout defines the variable name that will incapsulate the template

func (*Engine) Reload

func (e *Engine) Reload()

Reload if set to true the templates are reloading on each render, use it when you're in development and you don't want to restart the application when you edit a template file.

func (*Engine) SetPrefixTheme

func (e *Engine) SetPrefixTheme(theme string)

func (*Engine) SetTheme

func (e *Engine) SetTheme(theme string)

Theme sets theme

type IEngine

type IEngine interface {
	IEngineView
	Execute(out io.Writer, tpl string, binding any, layout ...string) error
}

type IEngineView

type IEngineView interface {
	AddFunc(name string, fn any)
	AddFuncMap(m map[string]any)
	Debug(enabled bool)
	Delims(left, right string)
	FuncMap() map[string]any
	Layout(key string)
	Reload()
	SetTheme(theme string)
	SetPrefixTheme(theme string)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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