htmltemplate

package
v0.0.0-...-91c01a0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PlaintextBlurb

func PlaintextBlurb(s string) string

PlaintextBlurb returns a plaintext blurb from markdown content.

Types

type Engine

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

Engine represents a HTML template engine.

func New

func New(manager *html.TemplateManager, allowUnsafeHTML bool) *Engine

New returns a HTML template engine.

func (*Engine) ErrorTemplate

func (te *Engine) ErrorTemplate(w http.ResponseWriter, r *http.Request, mainTemplate string,
	partialTemplate string, vars map[string]any) (status int, err error)

ErrorTemplate renders HTML to a response writer and returns a 404 status code and an error if one occurs.

func (*Engine) Post

func (te *Engine) Post(w http.ResponseWriter, r *http.Request, mainTemplate string,
	post model.Post, vars map[string]any) (status int, err error)

Post converts a site post from markdown to HTML and then outputs to response writer. Returns an HTTP status code and an error if one occurs.

func (*Engine) SanitizedHTML

func (te *Engine) SanitizedHTML(content string) []byte

SanitizedHTML returns a sanitized content html.

func (*Engine) Template

func (te *Engine) Template(w http.ResponseWriter, r *http.Request, mainTemplate string,
	partialTemplate string, vars map[string]any) (status int, err error)

Template renders HTML to a response writer and returns a 200 status code and an error if one occurs.

Jump to

Keyboard shortcuts

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