ui

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

README

go-ui

Some stuff I find helpful when building webapps.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assets

func Assets(r chi.Router, fs fs.FS)

Assets plumbs the assets into the router.

Types

type CtxConstructor

type CtxConstructor struct {
	Version         string
	JavascriptFiles []string
	HBTemplates     []HBTemplate
	StaticData      map[string]any
	// contains filtered or unexported fields
}

func (*CtxConstructor) NewContext

func (c *CtxConstructor) NewContext(ctx context.Context, data interface{}) *TemplateContext

type DataResolver

type DataResolver func(ctx context.Context) any

TODO: wonder if this should operate on the *http.Request instead of just a context

type HBTemplate

type HBTemplate struct {
	Name string
	Data template.HTML
}

func (HBTemplate) ID

func (t HBTemplate) ID() string

type LayerFS

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

func (*LayerFS) Filesystem

func (m *LayerFS) Filesystem() fs.FS

func (*LayerFS) Register

func (m *LayerFS) Register(s fs.FS)

type Manager

type Manager struct {
	Version              string
	RegistrationDisabled bool

	StaticData map[string]any
	// contains filtered or unexported fields
}

func NewManager

func NewManager(appVersion string, assets, templates fs.FS, staticData map[string]any, opts ...ManagerOption) *Manager

func (*Manager) Template

func (m *Manager) Template(name string, opts ...TemplateOption) (*template.Template, *CtxConstructor, error)

maybe it would be better to change additionalTemplates to functional options, so more JS, CSS files, etc. but this will work for now until a need arises

type ManagerOption

type ManagerOption func(*managerOptions)

func WithBaseHandlebarsTemplate

func WithBaseHandlebarsTemplate(templates ...string) ManagerOption

func WithBaseJavascriptFiles

func WithBaseJavascriptFiles(files ...string) ManagerOption

func WithBaseTemplates

func WithBaseTemplates(templates ...string) ManagerOption

func WithDataResolver

func WithDataResolver(name string, fn DataResolver) ManagerOption

type RemovePathElementFS

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

func NewRemovePathElementFS

func NewRemovePathElementFS(element string, position int, base fs.FS) *RemovePathElementFS

func (*RemovePathElementFS) Open

func (s *RemovePathElementFS) Open(name string) (fs.File, error)

type TemplateContext

type TemplateContext struct {
	Version         string
	Data            interface{}
	JavascriptFiles []string
	HBTemplates     []HBTemplate
	StaticData      map[string]any
	RequestData     map[string]any
}

type TemplateOption

type TemplateOption func(*templateOptions)

func WithAdditionalTemplates

func WithAdditionalTemplates(templates ...string) TemplateOption

func WithHandlebarsTemplate

func WithHandlebarsTemplate(templates ...string) TemplateOption

func WithJavascriptFiles added in v0.0.7

func WithJavascriptFiles(files ...string) TemplateOption

Jump to

Keyboard shortcuts

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