safe

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Namespace

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

Namespace defines the methods for safe to be used as template functions.

func New

func New(d *deps.Deps) *Namespace

Creates a new safe Namespace

func (*Namespace) CSS

func (ns *Namespace) CSS(i interface{}) (template.CSS, error)

CSS

Returns a given string as html/template HTML content. Returns errors.TEMPLATE if the inputted interface failed to be cast.

Example: {{ "<p>verbis&cms</p>" | safeHTML }} Returns: `verbis&amp;cms`

func (*Namespace) HTML

func (ns *Namespace) HTML(i interface{}) (template.HTML, error)

HTML

Returns a given string as html/template HTML content Returns errors.TEMPLATE if the inputted interface failed to be cast.

Example: {{ "<p>verbis&cms</p>" | safeHTML }} Returns: `verbis&cms`

func (*Namespace) HTMLAttr

func (ns *Namespace) HTMLAttr(i interface{}) (template.HTMLAttr, error)

HTMLAttr

Returns a given string as html/template HTMLAttr content. Returns errors.TEMPLATE if the inputted interface failed to be cast.

func (*Namespace) JS

func (ns *Namespace) JS(i interface{}) (template.JS, error)

JS

Returns a given string as html/template HTML content. Returns errors.TEMPLATE if the inputted interface failed to be cast.

Example: {{ "(2*2)" | safeJS }} Returns: `(2*2)`

func (*Namespace) JSStr

func (ns *Namespace) JSStr(i interface{}) (template.JSStr, error)

JSStr

Returns the given string as a html/template JSStr content. Returns errors.TEMPLATE if the inputted interface failed to be cast.

func (*Namespace) URL

func (ns *Namespace) URL(i interface{}) (template.URL, error)

URL

Returns a given string as html/template URL content. Returns errors.TEMPLATE if the inputted interface failed to be cast.

Example: {{ "https://verbiscms.com" | safeUrl }} Returns: `https://verbiscms.com`

Jump to

Keyboard shortcuts

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