Documentation ¶
Overview ¶
Package strings contains functions for dealing with strings.
Index ¶
- Variables
- func Contains(frame wdte.Frame, args ...wdte.Func) wdte.Func
- func Format(frame wdte.Frame, args ...wdte.Func) wdte.Func
- func Index(frame wdte.Frame, args ...wdte.Func) wdte.Func
- func Join(frame wdte.Frame, args ...wdte.Func) wdte.Func
- func Lower(frame wdte.Frame, args ...wdte.Func) wdte.Func
- func Prefix(frame wdte.Frame, args ...wdte.Func) wdte.Func
- func Read(frame wdte.Frame, args ...wdte.Func) wdte.Func
- func Repeat(frame wdte.Frame, args ...wdte.Func) wdte.Func
- func Split(frame wdte.Frame, args ...wdte.Func) wdte.Func
- func Suffix(frame wdte.Frame, args ...wdte.Func) wdte.Func
- func Upper(frame wdte.Frame, args ...wdte.Func) wdte.Func
Constants ¶
This section is empty.
Variables ¶
var Scope = wdte.S().Map(map[wdte.ID]wdte.Func{ "contains": wdte.GoFunc(Contains), "prefix": wdte.GoFunc(Prefix), "suffix": wdte.GoFunc(Suffix), "index": wdte.GoFunc(Index), "upper": wdte.GoFunc(Upper), "lower": wdte.GoFunc(Lower), "repeat": wdte.GoFunc(Repeat), "split": wdte.GoFunc(Split), "join": wdte.GoFunc(Join), "read": wdte.GoFunc(Read), "format": wdte.GoFunc(Format), })
Scope is a scope containing the functions in this package.
Functions ¶
func Contains ¶
Contains is a WDTE function with the following signatures:
contains outer inner (contains inner) outer
Returns true if inner is a substring of outer.
func Format ¶
Format is a WDTE function with the following signatures:
format tmpl ...
Format has some special rules for returning a partial function. For more information, see below.
This is the general-purpose string formatting function of the standard library, similar to Go's fmt.Sprintf(). Unlike fmt.Sprintf(), however, format uses a custom formatting specification. A format in the string tmpl is of the form {} with optional flags placed between them. Flags may be any combination of the following:
#<num> The zero-based index of the argument to be inserted. Subsequent formats will increment from here. In other words, '{2} {}' will yield the third and fourth arguments. q Place the value in quotes using strconv.Quote. ? Mark the value with it's underlying Go type, such as wdte.Number(3).
Format's rules for returning a partial function are dependant on the value of the first argument. Specifically, if the first argument attempts to substitute in more arguments than were given, a partial function will be returned. For example,
format '' # Returns '' format '{}' 3 # Returns '3' format '{}' # Returns a partial function. (format '{} {}' 3) 'example' # Returns '3 example'
Note that the total number of arguments required is the smallest number necessary to perform every substitution specified by the first argument. For example,
format '{3} {}'
will return a partial function that requires 5 arguments before it will return the formatted string.
TODO: Add more flags.
func Index ¶
Index is a WDTE function with the following signatures:
index outer inner (index inner) outer
It returns the index of the first character of the first instances of inner in outer. If inner is not a substring of outer, it returns -1.
func Join ¶ added in v0.3.4
Join is a WDTE function with the following signatures:
join strings sep (join sep) strings
It returns a new string containing the strings in the provided array with sep inserted between each.
func Lower ¶
Lower is a WDTE function with the following signature:
lower s
It returns s converted to lowercase.
func Prefix ¶
Prefix is a WDTE function with the following signatures:
prefix s p (prefix p) s
Returns true if p is a prefix of s.
func Read ¶ added in v0.5.0
Read is a WDTE function with the following signature:
read s
Returns a reader which reads from the string s.
func Repeat ¶ added in v0.3.4
Repeat is a WDTE function with the following signatures:
repeat string times (repeat string) times repeat times string (repeat times) string
It returns a new string containing the given string repeated the number of times specified.
func Split ¶ added in v0.3.5
Split is a WDTE function with the following signatures:
split string sep (split sep) string split string sep n (split sep n) string (split sep) string n
It splits the given string around instances of the given seperator string. If n is provided and is positive, the returned array of strings will have at most n elements. Note that this behavior differs from the Go standard library's string splitting function in that a zero value for n does not cause the function to return an empty array.
Types ¶
This section is empty.