urls

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package urls provides template functions to deal with URLs.

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 provides template functions for the "urls" namespace.

func New

func New(deps *deps.Deps) *Namespace

New returns a new instance of the urls-namespaced template functions.

func (*Namespace) AbsLangURL

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

AbsLangURL takes a given string and converts it to an absolute URL according to a page's position in the project directory structure and the current language.

func (*Namespace) AbsURL

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

AbsURL takes a given string and converts it to an absolute URL.

func (*Namespace) Anchorize

func (ns *Namespace) Anchorize(a interface{}) (string, error)

Anchorize creates sanitized anchor names that are compatible with Blackfriday.

func (*Namespace) Parse

func (ns *Namespace) Parse(rawurl interface{}) (*url.URL, error)

Parse parses rawurl into a URL structure. The rawurl may be relative or absolute.

func (*Namespace) Ref

func (ns *Namespace) Ref(in interface{}, args interface{}) (template.HTML, error)

Ref returns the absolute URL path to a given content item.

func (*Namespace) RelLangURL

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

RelLangURL takes a given string and prepends the relative path according to a page's position in the project directory structure and the current language.

func (*Namespace) RelRef

func (ns *Namespace) RelRef(in interface{}, args interface{}) (template.HTML, error)

RelRef returns the relative URL path to a given content item.

func (*Namespace) RelURL

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

RelURL takes a given string and prepends the relative path according to a page's position in the project directory structure.

func (*Namespace) URLDecode added in v0.3.0

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

URLDecode does the inverse transformation of QueryEscape, converting each 3-byte encoded substring of the form "%AB" into the hex-decoded byte 0xAB.

func (*Namespace) URLEncode added in v0.3.0

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

URLEncode escapes the string so it can be safely placed inside a URL query.

func (*Namespace) URLize

func (ns *Namespace) URLize(a interface{}) (string, error)

URLize returns the given argument formatted as URL.

Jump to

Keyboard shortcuts

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