ssr

package
v0.0.0-...-683b713 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package ssr provides utilities for server-side rendering of HTML pages which are sent to the client in response to HTTP requests.

Index

Constants

View Source
const TemplateExt = ".tmpl.html"

TemplateExt is the file extension used for templates.

Variables

This section is empty.

Functions

This section is empty.

Types

type TemplateSet

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

TemplateSet is a set of templates that can be rendered by the server.

func NewTemplateSet

func NewTemplateSet(fsys fs.FS, prefix string, base *string) (*TemplateSet, error)

NewTemplateSet creates a new template set from an FS, a given file prefix. Caller may optionally configure the template set with a base template, i.e. a template that is used as the base for all other templates.

func (*TemplateSet) Exec

func (ts *TemplateSet) Exec(w io.Writer, id string, data any) error

Exec executes the template with the given ID and data, writing the output to w.

func (*TemplateSet) Has

func (ts *TemplateSet) Has(id string) bool

Has returns true if the template with the given ID exists in the set.

Jump to

Keyboard shortcuts

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