Documentation
¶
Index ¶
- Variables
- func DefaultFuncMap() template.FuncMap
- func UserError(err error) string
- type Context
- type Controller
- type DOM
- type DefaultErrorView
- func (d DefaultErrorView) Content() string
- func (d DefaultErrorView) Extensions() []string
- func (d DefaultErrorView) FuncMap() template.FuncMap
- func (d DefaultErrorView) Layout() string
- func (d DefaultErrorView) LayoutContentName() string
- func (d DefaultErrorView) LiveEventReceiver() <-chan Event
- func (d DefaultErrorView) OnLiveEvent(ctx Context) error
- func (d DefaultErrorView) OnMount(ctx Context) (Status, M)
- func (d DefaultErrorView) Partials() []string
- type DefaultView
- func (d DefaultView) Content() string
- func (d DefaultView) Extensions() []string
- func (d DefaultView) FuncMap() template.FuncMap
- func (d DefaultView) Layout() string
- func (d DefaultView) LayoutContentName() string
- func (d DefaultView) LiveEventReceiver() <-chan Event
- func (d DefaultView) OnLiveEvent(ctx Context) error
- func (d DefaultView) OnMount(ctx Context) (Status, M)
- func (d DefaultView) Partials() []string
- type Event
- type EventHandler
- type M
- type Op
- type Operation
- type Option
- func DevelopmentMode(enable bool) Option
- func DisableTemplateCache() Option
- func EnableDebugLog() Option
- func EnableHTMLFormatting() Option
- func EnableWatch(rootDir string, extensions ...string) Option
- func WithErrorView(view View) Option
- func WithSubscribeTopic(f func(r *http.Request) *string) Option
- func WithUpgrader(upgrader websocket.Upgrader) Option
- type Status
- type Store
- type View
Constants ¶
This section is empty.
Variables ¶
var DefaultUserErrorMessage = "internal error"
var DefaultViewExtensions = []string{".gohtml", ".gotmpl", ".html", ".tmpl"}
var DefaultWatchExtensions = []string{".go", ".gohtml", ".gotmpl", ".html", ".tmpl"}
Functions ¶
func DefaultFuncMap ¶
Types ¶
type Controller ¶
type Controller interface {
Handler(view View) http.HandlerFunc
}
func Websocket ¶
func Websocket(name string, options ...Option) Controller
type DOM ¶
type DOM interface { SetDataset(selector string, data M) SetAttributes(selector string, data M) SetValue(selector string, value interface{}) SetInnerHTML(selector string, value interface{}) RemoveAttributes(selector string, data []string) ToggleClassList(selector string, classList map[string]bool) AddClass(selector, class string) RemoveClass(selector, class string) Morph(selector, template string, data M) Reload() }
type DefaultErrorView ¶ added in v0.0.4
type DefaultErrorView struct{}
func (DefaultErrorView) Content ¶ added in v0.0.4
func (d DefaultErrorView) Content() string
func (DefaultErrorView) Extensions ¶ added in v0.0.4
func (d DefaultErrorView) Extensions() []string
func (DefaultErrorView) FuncMap ¶ added in v0.0.4
func (d DefaultErrorView) FuncMap() template.FuncMap
func (DefaultErrorView) Layout ¶ added in v0.0.4
func (d DefaultErrorView) Layout() string
func (DefaultErrorView) LayoutContentName ¶ added in v0.0.4
func (d DefaultErrorView) LayoutContentName() string
func (DefaultErrorView) LiveEventReceiver ¶ added in v0.0.9
func (d DefaultErrorView) LiveEventReceiver() <-chan Event
func (DefaultErrorView) OnLiveEvent ¶ added in v0.0.9
func (d DefaultErrorView) OnLiveEvent(ctx Context) error
func (DefaultErrorView) OnMount ¶ added in v0.0.4
func (d DefaultErrorView) OnMount(ctx Context) (Status, M)
func (DefaultErrorView) Partials ¶ added in v0.0.4
func (d DefaultErrorView) Partials() []string
type DefaultView ¶ added in v0.0.3
type DefaultView struct{}
func (DefaultView) Content ¶ added in v0.0.3
func (d DefaultView) Content() string
Content returns either path to the content or a html string content
func (DefaultView) Extensions ¶ added in v0.0.3
func (d DefaultView) Extensions() []string
Extensions returns the view extensions. Defaults to: html, tmpl, gohtml, gotmpl
func (DefaultView) FuncMap ¶ added in v0.0.3
func (d DefaultView) FuncMap() template.FuncMap
FuncMap configures the html/template.FuncMap
func (DefaultView) Layout ¶ added in v0.0.3
func (d DefaultView) Layout() string
Layout returns either path to the layout or a html string layout Layout represents the path to the base layout to be used.
layout.html e.g. <!DOCTYPE html> <html lang="en"> <head> <title>{{.app_name}}</title> {{template "header" .}} </head> <body> {{template "navbar" .}} <div> {{template "content" .}} </div> {{template "footer" .}} </body> </html> The {{template "content" .}} directive is replaced by the page in the path exposed by `Content`
func (DefaultView) LayoutContentName ¶ added in v0.0.3
func (d DefaultView) LayoutContentName() string
LayoutContentName is the defined template of the "content" to be replaced. Defaults to "content"
e.g.
type SimpleView struct { glv.DefaultView }
func (s *SimpleView) Content() string { return `{{define "content"}}<div>world</div>{{ end }}` }
func (s *SimpleView) Layout() string { return `<div>Hello: {{template "content" .}}</div>` }
func (DefaultView) LiveEventReceiver ¶ added in v0.0.9
func (d DefaultView) LiveEventReceiver() <-chan Event
LiveEventReceiver is used to configure a receive only channel for receiving events from concurrent goroutines. e.g. a concurrent goroutine sends a tick event every second to the returned channel which is then handled in OnLiveEvent.
func (DefaultView) OnLiveEvent ¶ added in v0.0.9
func (d DefaultView) OnLiveEvent(ctx Context) error
OnLiveEvent handles the events sent from the browser or received on the LiveEventReceiver channel
func (DefaultView) OnMount ¶ added in v0.0.3
func (d DefaultView) OnMount(ctx Context) (Status, M)
OnMount is called when the page is first loaded for the http route.
func (DefaultView) Partials ¶ added in v0.0.3
func (d DefaultView) Partials() []string
Partials returns path to any partials used in the view. Defaults to "./templates/partials"
type Event ¶
type Event struct { ID string `json:"id"` Selector string `json:"selector"` Template string `json:"template"` Params json.RawMessage `json:"params"` }
func (Event) DecodeParams ¶
type EventHandler ¶
type Operation ¶
type Option ¶
type Option func(*controlOpt)
func DevelopmentMode ¶ added in v0.0.4
func DisableTemplateCache ¶
func DisableTemplateCache() Option
func EnableDebugLog ¶
func EnableDebugLog() Option
func EnableHTMLFormatting ¶
func EnableHTMLFormatting() Option