templates

package
v0.81.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package templates provides tree-based template loading and rendering using HTML templates from the Go standard library.

Use Templates to obtain an acceptable.Processor loaded with the specified template files.

Index

Constants

This section is empty.

Variables

View Source
var DefaultPage = "_index.html"

DefaultPage is the template name when a blank string is supplied. Alter this during startup if required.

Fs is used to obtain file information and content. It can be stubbed for testing.

View Source
var GZIPLevel = offer.MidCompression

GZIPLevel sets the compression strength when gzip is applied to a response entity. This is in the range 1 to 9 inclusive (see gzip.NewWriterLevel). High values should be avoided because the cpu cost is high but the benefit may not be sufficient.

This controls template responses only.

View Source
var ReloadOnTheFly = false

ReloadOnTheFly enables a development mode that reloads template files whenever they change, without restarting the server. This reduces performance and should be off (false) for production.

Functions

func ApplicationXhtmlOffer

func ApplicationXhtmlOffer(dir, suffix string, funcMap template.FuncMap) offer.Offer

ApplicationXhtmlOffer is an Offer for application/xhtml+xml content using the Template() processor.

func Templates

func Templates(dir, suffix string, funcMap template.FuncMap) offer.Processor

Templates finds all the templates in the directory dir and its subdirectories that have names ending with the given suffix (usually ".html").

Optionally, the suffix can be a pipe-separated list, e.g. ".html|.js".

The function map (see template.FuncMap) can be nil if not required.

A processor is returned that handles requests using the templates available.

The response will use gzip compression (see GZIPLevel) when the client requests it.

func TextHtmlOffer

func TextHtmlOffer(dir, suffix string, funcMap template.FuncMap) offer.Offer

TextHtmlOffer is an Offer for text/html content using the Template() processor.

Types

This section is empty.

Jump to

Keyboard shortcuts

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