htmltemplate

package
v0.0.0-...-f8b8a36 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 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) RenderMarkdown

func (te *Engine) RenderMarkdown(markdown string) template.HTML

RenderMarkdown renders markdown to 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