Documentation ¶
Index ¶
- Variables
- func FormTemplateContext(tw *Template[FormContext]) func(ctx httpx.FormContext, r *http.Request) any
- type FlagFunc
- func Actions(actions ...component.MenuItem) FlagFunc
- func Assets(Assets assets.Assets) FlagFunc
- func Crumbs(crumbs ...component.MenuItem) FlagFunc
- func ReplaceAction(old component.MenuItem, action component.MenuItem) FlagFunc
- func ReplaceCrumb(old component.MenuItem, action component.MenuItem) FlagFunc
- func Title(title string) FlagFunc
- type Flags
- type FormContext
- type Parsed
- type RuntimeFlags
- type Template
- func (tpl *Template[C]) Context(r *http.Request, c C, funcs ...FlagFunc) (ctx *tContext[C])
- func (tw *Template[C]) HTMLHandler(worker func(r *http.Request) (C, error)) httpx.HTMLHandler[any]
- func (tw *Template[C]) HTMLHandlerWithFlags(worker func(r *http.Request) (C, []FlagFunc, error)) httpx.HTMLHandler[any]
- func (tw *Template[C]) Handler(f func(r *http.Request) (C, error)) func(r *http.Request) (any, error)
- func (tw *Template[C]) HandlerWithFlags(worker func(r *http.Request) (C, []FlagFunc, error)) func(r *http.Request) (any, error)
- func (tpl *Template[C]) Template() *template.Template
- type Templating
- func (tpl *Templating) Backup(context *component.StagingContext) error
- func (tpl *Templating) BackupName() string
- func (tpl *Templating) CustomAssetPath(name string) string
- func (tpl *Templating) CustomAssetsPath() string
- func (tpl *Templating) GetCustomizable(dflt *template.Template) *template.Template
- func (tpl *Templating) Menu(r *http.Request) []component.MenuItem
Constants ¶
This section is empty.
Variables ¶
var ParseForm = Parse[FormContext]
ParseForm is like Parse[BaseFormContext]
Functions ¶
func FormTemplateContext ¶
func FormTemplateContext(tw *Template[FormContext]) func(ctx httpx.FormContext, r *http.Request) any
FormTemplateContext returns a new handler for a form with the given base context
Types ¶
type FlagFunc ¶
FlagFunc updates a flags based on a request. FlagFunc may not be nil.
func ReplaceAction ¶
ReplaceAction replaces a specific action
func ReplaceCrumb ¶
ReplaceCrumb replaces a specific crum
type Flags ¶
type Flags struct { Title string // Title of the menu assets.Assets // assets are the assets included in the template Crumbs []component.MenuItem // crumbs are the breadcrumbs leading to a specific action Actions []component.MenuItem // actions are the actions available to a specific thingy }
Flags represent handle-updatable options for the base template
type FormContext ¶
type FormContext struct { httpx.FormContext RuntimeFlags }
func NewFormContext ¶
func NewFormContext(context httpx.FormContext) FormContext
NewFormContext returns a new FormContext from an underlying context
type Parsed ¶
type Parsed[C any] struct { // contains filtered or unexported fields }
Parsed represents a parsed template that takes as argument a context of type C.
type RuntimeFlags ¶
type RuntimeFlags struct { Flags RequestURI string // request uri of the current page Menu []component.MenuItem // menu at the top of the page GeneratedAt time.Time // time the underlying data returned CSRF template.HTML // csrf data (if any) }
RuntimeFlags are passed to the template at runtime.
type Template ¶
type Template[C any] struct { // contains filtered or unexported fields }
Tempalte represents an executable template.
func (*Template[C]) Context ¶
Context generates the context to pass to an instance of the template returned by Template.
func (*Template[C]) HTMLHandler ¶
HTMLHandler creates a new httpx.HTMLHandler that calls tw.Handler(worker) and tw.Template. See also Handler.
func (*Template[C]) HTMLHandlerWithFlags ¶
func (tw *Template[C]) HTMLHandlerWithFlags(worker func(r *http.Request) (C, []FlagFunc, error)) httpx.HTMLHandler[any]
HTMLHandlerWithFlags creates a new httpx.HTMLHandler that calls tw.HandlerWithFlags(worker) and tw.Template. See also HandlerWithFlags.
func (*Template[C]) Handler ¶
func (tw *Template[C]) Handler(f func(r *http.Request) (C, error)) func(r *http.Request) (any, error)
HandlerWithFlags returns a function that, given a request, generates context and error to pass to the generated template. The worker implements the actual buisness logic, it takes a request, and returns the content for the main template, and any error. See also HandlerWithFlags.
func (*Template[C]) HandlerWithFlags ¶
func (tw *Template[C]) HandlerWithFlags(worker func(r *http.Request) (C, []FlagFunc, error)) func(r *http.Request) (any, error)
HandlerWithFlags returns a function that, given a request, generates context and error to pass to the generated template. The worker implements the actual buisness logic, it takes a request, and returns the content for the main template, flag functions and error. See also Handler.
type Templating ¶
type Templating struct { component.Base Dependencies struct { Routeables []component.Routeable Menuable []component.Menuable } // contains filtered or unexported fields }
Templating implements templating customization
func (*Templating) Backup ¶
func (tpl *Templating) Backup(context *component.StagingContext) error
func (*Templating) BackupName ¶
func (tpl *Templating) BackupName() string
func (*Templating) CustomAssetPath ¶
func (tpl *Templating) CustomAssetPath(name string) string
func (*Templating) CustomAssetsPath ¶
func (tpl *Templating) CustomAssetsPath() string
CustomAssetsPath is the path custom assets are stored at
func (*Templating) GetCustomizable ¶
func (tpl *Templating) GetCustomizable(dflt *template.Template) *template.Template
GetCustomizable returns either a clone of dflt, or the overriden template with the same name.