Other Utilities

Other utilities #

center #

func center(width interface{}, args ...interface{}) string
Returns the concatenation of supplied arguments centered within width.

Aliases #

  • centered

color #

func color(args ...interface{}) string
Colors the rendered string.

The first arguments are interpretated as color attributes until the
first non color attribute. Attributes are case insensitive.

Valid attributes are:
Reset, Bold, Faint, Italic, Underline, BlinkSlow, BlinkRapid,
    ReverseVideo, Concealed, CrossedOut

Valid color are:
    Black, Red, Green, Yellow, Blue, Magenta, Cyan, White

Color can be prefixed by:
    Fg: Meaning foreground (Fg is assumed if not specified)
    FgHi: Meaning high intensity foreground
    Bg: Meaning background"
    BgHi: Meaning high intensity background

Aliases #

  • colored
  • enhanced

colorln #

func colorln(args ...interface{}) string
Same as color, but using sprintln instead of sprint to format
arguments

concat #

func concat(args ...interface{}) string
Returns the concatenation (without separator) of the string
representation of objects.

formatList #

func formatList(format string, list ...interface{}) IGenericList
Return a list of strings by applying the format to each element of the
supplied list.

You can also use autoWrap as Razor expression if you don't want to
specify the format.
The format is then automatically induced by the context around the
declaration).
Valid aliases for autoWrap are: aWrap, awrap.

Ex:
    Hello @<autoWrap(to(10)) World!

Aliases #

  • autoWrap
  • aWrap
  • awrap

id #

func id(identifier string, replaceChar ...interface{}) string
Returns a valid go identifier from the supplied string (replacing any
non compliant character by replacement, default _ ).

Aliases #

  • identifier

iif #

func iif(testValue interface{}, valueTrue interface{}, valueFalse
interface{}) interface{}
If testValue is empty, returns falseValue, otherwise returns
trueValue.
    WARNING: All arguments are evaluated and must by valid.

Aliases #

  • ternary

indent #

func indent(nbSpace int, args ...interface{}) string
Indents every line in a given string to the specified indent width.
This is useful when aligning multi-line strings.

joinLines #

func joinLines(format ...interface{}) string
Merge the supplied objects into a newline separated string.

lorem #

func lorem(loremType interface{}, params ...int) string
Returns a random string. Valid types are be word, words, sentence,
para, paragraph, host, email, url.

Aliases #

  • loremIpsum

mergeList #

func mergeList(lists ...IGenericList) IGenericList
Return a single list containing all elements from the lists supplied.

nIndent #

func nIndent(nbSpace int, args ...interface{}) string
Work as indent but add a newline before.

Aliases #

  • nindent

raw #

func raw(args ...interface{}) interface{}
Print the arguments outside of their enclosing quotes

Aliases #

  • printRaw

rawList #

func rawList(args ...interface{}) interface{}
Print the arguments outside of their enclosing quotes (no or single
argument are considered as a list)

reCompile #

func reCompile(arg1 string) *regexp.Regexp
Parses a regular expression and returns Regexp object that can be used
to match against text.

repeat #

func repeat(n int, element interface{}) IGenericList
Returns an array with the item repeated n times.

sIndent #

func sIndent(spacer string, args ...interface{}) string
Indents the elements using the provided spacer.

You can also use autoIndent as Razor expression if you don't want to
specify the spacer.
Spacer will then be auto determined by the spaces that precede the
expression.
Valid aliases for autoIndent are: aIndent, aindent.

Aliases #

  • sindent
  • spaceIndent
  • autoIndent
  • aindent
  • aIndent

splitLines #

func splitLines(content interface{}) []interface{}
Returns a list of strings from the supplied object with newline as the
separator.

stripColor #

func stripColor(arg1 interface{}) string
Remove all ANSI colors & attributes from a string.

Aliases #

  • stripansi
  • stripANSI
  • striptcolor

wrap #

func wrap(width interface{}, args ...interface{}) string
Wraps the rendered arguments within width.

Aliases #

  • wrapped