Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Templater = tmplutil.Templater{ FileSystem: embedFS, Includes: map[string]string{ "css": "components/css.html", "header": "components/header.html", "footer": "components/footer.html", "empty-card": "components/empty-card.html", }, Functions: template.FuncMap{ "markup": func(input string) template.HTML { return template.HTML(markup.ToHTML(input)) }, "rgbaHex": func(rgba [4]float32) string { color := colorful.FastLinearRgb( float64(rgba[0]), float64(rgba[1]), float64(rgba[2]), ) return color.Hex() }, "shortErr": func(err string) string { parts := strings.Split(err, ": ") if len(parts) == 0 { return "" } part := parts[len(parts)-1] r, sz := utf8.DecodeRuneInString(part) if sz == 0 { return "" } return string(unicode.ToUpper(r)) + part[sz:] + "." }, }, }
Functions ¶
func ExecuteNamedTemplate ¶
func ExecuteNamedTemplate(w http.ResponseWriter, r *http.Request, name string)
ExecuteNamedTemplate executes the named template with the RenderState.
func ExecuteTemplate ¶
func ExecuteTemplate(w http.ResponseWriter, r *http.Request, sub *tmplutil.Subtemplate)
ExecuteTemplate executes the template with the RenderState.
func InjectRenderState ¶
func InjectRenderState(state RenderState) func(http.Handler) http.Handler
InjectRenderState injects the render state.
Types ¶
type RenderState ¶
type RenderState struct { Client *distance.Client Observer *distance.Observer SiteName string DistanceURL *url.URL }
func GetRenderState ¶
func GetRenderState(ctx context.Context) RenderState
GetRenderState gets the render state inside the given context.
Click to show internal directories.
Click to hide internal directories.