Documentation
¶
Overview ¶
Package template provides templates for rendering HTML pages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrFailedToParse = errors.New("failed to parse templates")
ErrFailedToParse is an error that is returned when the templates fail to parse.
Functions ¶
func RenderTemplateHTML ¶
func RenderTemplateHTML[T any](template Templater[T], w http.ResponseWriter, data T) error
RenderTemplateHTML sets the Content-Type header to text/html and executes the given template.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is a Templater that uses embedded templates.
func NewEmbedded ¶
func NewEmbedded() *Engine
NewEmbedded creates a new template engine using the embedded templates.
func (*Engine) HomePage ¶
func (tfs *Engine) HomePage() PageTemplate[HomePageData]
HomePage returns a handle to the template for the home page.
type HomePageData ¶
type HomePageData struct{}
HomePageData is the data needed to render the home page.
type PageTemplate ¶
type PageTemplate[T any] struct { // contains filtered or unexported fields }
PageTemplate is a template for a specific page.
func (PageTemplate[T]) ExecuteTemplate ¶
func (p PageTemplate[T]) ExecuteTemplate(wr io.Writer, data T) error
ExecuteTemplate executes a template with the given data.
Click to show internal directories.
Click to hide internal directories.