theophilusx.yorick.utils

A collection of useful utility functions to assist in working with components.

cs

(cs & names)

Build a string of CSS class names from the arguments provided. Arguments can be a string, keyword or vector of strings. If the argument is a keyword, it is converted to a string using name.

ensure-vector

(ensure-vector v)

If v is not a vector wrap it in a vector and return it, otherwise just return v.

initcaps

(initcaps s)

Convert the first letter of each word in the string s to a capital.

keyword->str

(keyword->str kw & {:keys [initial-caps]})

Convert a keyword kw to a `string``. Any dash (-) characters in the keyword are converted to spaces.

number-thousands

(number-thousands num-str)

Format the string argument num-str with commas to indicate thousands.

spath

(spath kw & {:keys [prefix]})

Convert the keyword kw to a vector representing a path for a nested map structure. If the keyword contains any periods ., they are interpreted as path separators e.g. :a.b.c becomes [:a :b :c]. All pat segments are interpreted as keywords. If the optional keyword argument :prefix is supplied, it is added as the first segment of the path.

str-format

(str-format fmt & args)

Use goog.string/format to format the arguments args with the format fmt.

value->keyword

(value->keyword v)

Generates a keyword from the value v. Any spaces, commas, colons or ampersands are converted to a dash (-).

value-of

(value-of e)

Extract the value attribute from the target property of the element e.

vector-of-vectors

(vector-of-vectors v)

Return true if v is a vector of vectors.