You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/custom-api.md
+12-1
Original file line number
Diff line number
Diff line change
@@ -325,13 +325,24 @@ The following helper functions provided by Glance are available:
325
325
-`toFloat(i int) float`: Converts an integer to a float.
326
326
-`toInt(f float) int`: Converts a float to an integer.
327
327
-`toRelativeTime(t time.Time) template.HTMLAttr`: Converts Time to a relative time such as 2h, 1d, etc which dynamically updates. **NOTE:** the value of this function should be used as an attribute in an HTML tag, e.g. `<span {{ toRelativeTime .Time }}></span>`.
328
-
-`parseTime(layout string, s string) time.Time`: Parses a string into time.Time. The layout must be provided in Go's [date format](https://pkg.go.dev/time#pkg-constants). You can alternatively use these values instead of the literal format: "RFC3339", "RFC3339Nano", "DateTime", "DateOnly", "TimeOnly".
328
+
-`parseTime(layout string, s string) time.Time`: Parses a string into time.Time. The layout must be provided in Go's [date format](https://pkg.go.dev/time#pkg-constants). You can alternatively use these values instead of the literal format: "unix", "RFC3339", "RFC3339Nano", "DateTime", "DateOnly".
329
+
-`parseRelativeTime(layout string, s string) time.Time`: A shorthand for `{{ .String "date" | parseTime "rfc3339" | toRelativeTime }}`.
329
330
-`add(a, b float) float`: Adds two numbers.
330
331
-`sub(a, b float) float`: Subtracts two numbers.
331
332
-`mul(a, b float) float`: Multiplies two numbers.
332
333
-`div(a, b float) float`: Divides two numbers.
333
334
-`formatApproxNumber(n int) string`: Formats a number to be more human-readable, e.g. 1000 -> 1k.
334
335
-`formatNumber(n float|int) string`: Formats a number with commas, e.g. 1000 -> 1,000.
336
+
-`trimPrefix(prefix string, str string) string`: Trims the prefix from a string.
337
+
-`trimSuffix(suffix string, str string) string`: Trims the suffix from a string.
338
+
-`trimSpace(str string) string`: Trims whitespace from a string on both ends.
339
+
-`replaceAll(old string, new string, str string) string`: Replaces all occurrences of a string in a string.
340
+
-`findMatch(pattern string, str string) string`: Finds the first match of a regular expression in a string.
341
+
-`findSubmatch(pattern string, str string) string`: Finds the first submatch of a regular expression in a string.
342
+
-`sortByString(key string, order string, arr []JSON): []JSON`: Sorts an array of JSON objects by a string key in either ascending or descending order.
343
+
-`sortByInt(key string, order string, arr []JSON): []JSON`: Sorts an array of JSON objects by an integer key in either ascending or descending order.
344
+
-`sortByFloat(key string, order string, arr []JSON): []JSON`: Sorts an array of JSON objects by a float key in either ascending or descending order.
345
+
-`sortByTime(key string, layout string, order string, arr []JSON): []JSON`: Sorts an array of JSON objects by a time key in either ascending or descending order. The format must be provided in Go's [date format](https://pkg.go.dev/time#pkg-constants).
335
346
336
347
The following helper functions provided by Go's `text/template` are available:
0 commit comments