Documentation
¶
Index ¶
- Variables
- func DefaultRoot() string
- func RegisterFunc(name string, fn any)
- func RegisterFuncs(funcs template.FuncMap)
- func RegisterPluginViews(prefix string, filesystem fs.FS)
- func Render(name string, data any) (string, error)
- func SetRoot(root string)
- type Context
- type Engine
- type Props
- func (p *Props) Except(keys []any) *Props
- func (p *Props) Get(key string, fallback ...any) any
- func (p *Props) Has(key string) bool
- func (p *Props) Merge(defaults map[string]any) *Props
- func (p *Props) MergeIf(cond bool, defaults map[string]any) *Props
- func (p *Props) MergeUnless(cond bool, defaults map[string]any) *Props
- func (p *Props) Only(keys []any) *Props
- func (p *Props) ToAttrs() template.HTMLAttr
Constants ¶
This section is empty.
Variables ¶
var OnRendered func(name string, duration time.Duration, data any)
OnRendered is called after a successful template render.
Functions ¶
func DefaultRoot ¶ added in v1.6.0
func DefaultRoot() string
DefaultRoot returns the default engine's template directory, or "" when no engine has been set up. The startup view uses it to decide whether the app renders views at all.
func RegisterFunc ¶
RegisterFunc registers a global template function.
func RegisterFuncs ¶
RegisterFuncs registers multiple global template functions.
func RegisterPluginViews ¶
RegisterPluginViews registers an embedded FS for views.
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context represents the provide/inject context store.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine renders .nimbus templates (Edge-style: {{ variable }}, {{{ raw }}}, @if, @each, @layout, @component).
var Default *Engine
Default engine.
func New ¶
New creates a view engine with views loaded from root (e.g. "views"). Templates use .nimbus extension.
func (*Engine) Render ¶
Render renders the named view (e.g. "home" -> views/home.nimbus) with data. Supports @layout('layout') like Edge.
func (*Engine) RenderWriter ¶
RenderWriter writes the rendered view to w.
type Props ¶
type Props struct {
// contains filtered or unexported fields
}
Props represents HTML element attributes and helper APIs.
func (*Props) MergeUnless ¶
MergeUnless merges defaults if condition is false.