Documentation
¶
Overview ¶
Package strings provides methods for manipulating strings in templates
Index ¶
- func Bracket(item any) string
- func BracketWith(bracketPair string, item any) (string, error)
- func Functions() template.FuncMap
- func HasPrefix(prefix string, subject string) bool
- func HasSuffix(suffix string, subject string) bool
- func Indent(count int, content string) string
- func Newline(count ...int) string
- func PadLeft(n int, s any) string
- func PadRight(n int, s any) string
- func Prefix(prefix string, count int, content string) string
- func QuoteBack(item any) string
- func QuoteDouble(item any) string
- func QuoteSingle(item any) string
- func Rep(count int, item ...string) string
- func Space(n int) string
- func SplitOn(glue string, content string) []string
- func Suffix(suffix string, count int, content string) string
- func Tab(n int) string
- func TabIndent(count int, content string) string
- func TitleCaseWithAbbr(abbrev any, word string) (string, error)
- func ToColumn(width int, content string) string
- func TrimPrefix(prefix string, subject string) string
- func TrimSuffix(suffix string, subject string) string
- func TypeKind(value any) string
- func TypeName(value any) string
- func Unindent(count int, content string) (string, error)
- func UppercaseFirst(s any) string
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BracketWith ¶
BracketWith adds brackets of a given type around the given string
func HasPrefix ¶ added in v0.10.2
HasPrefix returns true if the supplied string has the given prefix
func HasSuffix ¶ added in v0.10.2
HasSuffix returns true if the supplied string has the given suffix
func Indent ¶
Indent prints the given string with the given number of spaces prepended before each line
func Prefix ¶
Prefix prints the given string with the given number of 'prefix' prepended before each line
func QuoteDouble ¶
QuoteDouble adds double quote around the given string
func QuoteSingle ¶
QuoteSingle adds single quote around the given string
func Suffix ¶
Suffix prints the given string with the given number of 'suffix' appended to each line
func TabIndent ¶
TabIndent prints the given string with the given number of spaces prepended before each line
func TitleCaseWithAbbr ¶
TitleCaseWithAbbr upper-cases the first letter of each word, or the whole word if it matches a given abbreviation
func ToColumn ¶
ToColumn formats the given text to not take more than 'w' characters per line, splitting on the space before the word that would take the line over. If no space can be found, the line isn't split (ie words bigger than the line size are printed un-split)
Example ¶
ExampleToColumn
w := 40 s := "Lorem ipsum dolor\nsit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat." got := ToColumn(w, s) fmt.Println(got)
Output: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
func TrimPrefix ¶ added in v0.10.2
TrimPrefix removes the given prefix from the supplied string, or does nothing if the string doesn't have the prefix
func TrimSuffix ¶ added in v0.10.2
TrimSuffix removes the given suffix from the supplied string, or does nothing if the string doesn't have the suffix
func UppercaseFirst ¶
UppercaseFirst converts the first character in a string to uppercase
Types ¶
This section is empty.