tmpl

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsoluteURLs

func AbsoluteURLs(args ...reflect.Value) (interface{}, error)

AbsoluteURLs converts all path based urls in html to be absolute, as needed in Atom and RSS feeds. It expects two arguments, the base url and the HTML.

func DateFormat

func DateFormat(args ...reflect.Value) (interface{}, error)

DateFormat formats the date according to the format. It expects exactly two arguments, a format (which follows the patterns used by Go's Time.Format) and a date, which can either be a date or a string in RFC3339 format, or a date object

func EscapeHTML

func EscapeHTML(args ...reflect.Value) (interface{}, error)

EscapeHTML escapes the string using html.EscapeString

func Filter

func Filter(args ...reflect.Value) (interface{}, error)

Filter returns any elements of list where the data at key matches value. It expects three args, a key, a value and a list. Equality is tested using the go == operator.

func First

func First(args ...reflect.Value) (interface{}, error)

First returns the first count elements of list. It expects either an integer count and a slice or array list. The count defaults to 1 if not provided.

func Last added in v0.0.2

func Last(args ...reflect.Value) (interface{}, error)

Last returns the last count elements of list. It expects either an integer count and a slice or array list. The count defaults to 1 if not provided.

func Map

func Map() template.FuncMap

Map returns the template helpers as a html/template.FuncMap

func Now

func Now() time.Time

Now returns the current time.

func Sort

func Sort(args ...reflect.Value) (interface{}, error)

Sort sorts a list using the provided key and direction ("asc" or "desc"). If a direction is not provided it defaults to "asc". Args are either "key, direction, list" or just "key, direction"

func XMLDecl

func XMLDecl(args ...reflect.Value) (interface{}, error)

XMLDecl outputs the XML declaration <?xml version="1.0" encoding="utf-8"?>. We shouldn't really use html/template to generate XML but it works, except for the declaration. This function is a workaround for that.

Types

This section is empty.

Jump to

Keyboard shortcuts

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