Documentation ¶
Index ¶
- type Namespace
- func (ns *Namespace) Chomp(s interface{}) (interface{}, error)
- func (ns *Namespace) Contains(s, substr interface{}) (bool, error)
- func (ns *Namespace) ContainsAny(s, chars interface{}) (bool, error)
- func (ns *Namespace) CountRunes(s interface{}) (int, error)
- func (ns *Namespace) CountWords(s interface{}) (int, error)
- func (ns *Namespace) FindRE(expr string, content interface{}, limit ...interface{}) ([]string, error)
- func (ns *Namespace) HasPrefix(s, prefix interface{}) (bool, error)
- func (ns *Namespace) HasSuffix(s, suffix interface{}) (bool, error)
- func (ns *Namespace) Repeat(n, s interface{}) (string, error)
- func (ns *Namespace) Replace(s, old, new interface{}) (string, error)
- func (ns *Namespace) ReplaceRE(pattern, repl, s interface{}) (_ string, err error)
- func (ns *Namespace) RuneCount(s interface{}) (int, error)
- func (ns *Namespace) SliceString(a interface{}, startEnd ...interface{}) (string, error)
- func (ns *Namespace) Split(a interface{}, delimiter string) ([]string, error)
- func (ns *Namespace) Substr(a interface{}, nums ...interface{}) (string, error)
- func (ns *Namespace) Title(s interface{}) (string, error)
- func (ns *Namespace) ToLower(s interface{}) (string, error)
- func (ns *Namespace) ToUpper(s interface{}) (string, error)
- func (ns *Namespace) Trim(s, cutset interface{}) (string, error)
- func (ns *Namespace) TrimLeft(cutset, s interface{}) (string, error)
- func (ns *Namespace) TrimPrefix(prefix, s interface{}) (string, error)
- func (ns *Namespace) TrimRight(cutset, s interface{}) (string, error)
- func (ns *Namespace) TrimSuffix(suffix, s interface{}) (string, error)
- func (ns *Namespace) Truncate(a interface{}, options ...interface{}) (template.HTML, error)
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 "strings" namespace. Most functions mimic the Go stdlib, but the order of the parameters may be different to ease their use in the Go template system.
func (*Namespace) ContainsAny ¶
ContainsAny reports whether any Unicode code points in chars are within s.
func (*Namespace) CountRunes ¶
CountRunes returns the number of runes in s, excluding whitepace.
func (*Namespace) CountWords ¶
CountWords returns the approximate word count in s.
func (*Namespace) FindRE ¶
func (ns *Namespace) FindRE(expr string, content interface{}, limit ...interface{}) ([]string, error)
FindRE returns a list of strings that match the regular expression. By default all matches will be included. The number of matches can be limited with an optional third parameter.
func (*Namespace) Repeat ¶ added in v0.42.1
Repeat returns a new string consisting of count copies of the string s.
func (*Namespace) Replace ¶
Replace returns a copy of the string s with all occurrences of old replaced with new.
func (*Namespace) ReplaceRE ¶
ReplaceRE returns a copy of s, replacing all matches of the regular expression pattern with the replacement text repl.
func (*Namespace) SliceString ¶
SliceString slices a string by specifying a half-open range with two indices, start and end. 1 and 4 creates a slice including elements 1 through 3. The end index can be omitted, it defaults to the string's length.
func (*Namespace) Substr ¶
Substr extracts parts of a string, beginning at the character at the specified position, and returns the specified number of characters.
It normally takes two parameters: start and length. It can also take one parameter: start, i.e. length is omitted, in which case the substring starting from start until the end of the string will be returned.
To extract characters from the end of the string, use a negative start number.
In addition, borrowing from the extended behavior described at http://php.net/substr, if length is given and is negative, then that many characters will be omitted from the end of string.
func (*Namespace) Title ¶
Title returns a copy of the input s with all Unicode letters that begin words mapped to their title case.
func (*Namespace) ToLower ¶
ToLower returns a copy of the input s with all Unicode letters mapped to their lower case.
func (*Namespace) ToUpper ¶
ToUpper returns a copy of the input s with all Unicode letters mapped to their upper case.
func (*Namespace) Trim ¶
Trim returns a string with all leading and trailing characters defined contained in cutset removed.
func (*Namespace) TrimLeft ¶ added in v0.27.1
TrimLeft returns a slice of the string s with all leading characters contained in cutset removed.
func (*Namespace) TrimPrefix ¶
TrimPrefix returns s without the provided leading prefix string. If s doesn't start with prefix, s is returned unchanged.
func (*Namespace) TrimRight ¶ added in v0.27.1
TrimRight returns a slice of the string s with all trailing characters contained in cutset removed.
func (*Namespace) TrimSuffix ¶
TrimSuffix returns s without the provided trailing suffix string. If s doesn't end with suffix, s is returned unchanged.