Modifiers
Tiny functions that power the Sintax module.
Modifiers are functions that shorten the path of data transformation.
Boolean
Compare values and return true or false. Combine with conditionals to branch template output.
| Modifier | Description |
|---|---|
eq | Eq returns true if the value equals the given parameter. |
gt | Gt returns true if the numeric value is greater than the threshold. |
gte | Gte returns true if the numeric value is greater than or equal to the threshold. |
not | Not inverts the truthiness of the value. |
Collections
Work with arrays and maps — sort, filter, find, extract keys, and reshape data.
| Modifier | Description |
|---|---|
filter | Filter returns a subset of a slice where a nested field matches a value. |
find | Find returns the first element in a slice or map where a field equals the given value. |
first | First returns the first character of a string or the first element of a slice. |
has | Has returns true if the slice or map contains the given value. |
is | Is returns true if the value equals any of the given parameters. |
key | Key extracts a value from a map or slice by key path or index. |
last | Last returns the last character of a string or the last element of a slice. |
map | Map converts a slice of maps into a map keyed by the given field's string value. |
merge | Merge converts a slice of maps into a map keyed by the given field's string value. |
sort | Sort sorts a slice in ascending or descending order. |
wrap | Wrap wraps the value in a map under the given key. |
Convert
Serialize and deserialize between Go values, JSON, and YAML.
| Modifier | Description |
|---|---|
from | From parses the string value as the given format and returns the parsed result. |
json | JSON serializes the value to a JSON string. |
markdown | Markdown converts an HTML string to Markdown. |
yaml | YAML serializes or parses a value as YAML. |
File System
Extract and manipulate path components — directory, filename, and extension.
| Modifier | Description |
|---|---|
dirname | Dirname returns the directory portion of a file path. |
ext | FilenameExt returns the file extension without the leading dot. |
ext-dot | FilenameExtDot returns the file extension including the leading dot. |
ext-prepend | FilenamePrependExt inserts an additional extension before the existing file extension. |
ext-trim | FilenameTrimExt returns the file path without its extension. |
filename | Filename returns the base file name from a path, including the extension. |
Money
Convert between currency units and denominations.
| Modifier | Description |
|---|---|
currency | Currency converts a numeric value between currency units by applying a unit multiplier ratio. |
Text
Manipulate strings — trim whitespace, change case, split, join, slugify, and more.
| Modifier | Description |
|---|---|
concat | Concat appends one or more strings to the value. |
join | Join combines an array of strings into a single string with a separator. |
lines | Lines splits a string or byte slice into an array of lines. |
lower | ToLower converts a string to lowercase. |
replace | Replace replaces all occurrences of a substring within the string value. |
replace_pattern | ReplacePattern replaces all regex matches within the string value. |
reverse | Reverse reverses the characters in a string. |
sexy | Sexy returns a bear ASCII art. |
shorten | Shorten truncates a string to the given maximum character length. |
slug | Slug converts a string to a URL-friendly slug. |
split | Split splits a string into an array using a separator. |
title | Title converts a hyphen-separated slug into a title-cased string. |
title_model | ModelTitle formats an AI model identifier into a human-readable title. |
trim | Trim removes leading and trailing whitespace, or the given character set. |
trim-prefix | TrimPrefix removes a leading prefix string or leading whitespace from the value. |
trim-suffix | TrimSuffix removes a trailing suffix string or trailing whitespace from the value. |
upper | ToUpper converts a string to uppercase. |
Utilities
General-purpose modifiers — defaults, lengths, line numbers, and date formatting.
| Modifier | Description |
|---|---|
default | Default returns the fallback value if the input is nil or an empty string. |
format | Format formats a time. |
length | Length returns the number of characters in a string or bytes in a byte slice. |
line-numbers | LineNumbers prepends each line of the string with its zero-based line number. |
How is this guide?