This commit is contained in:
Manfred Touron
2017-05-18 18:54:23 +02:00
parent dc386661ca
commit 5448f25fd6
645 changed files with 55908 additions and 33297 deletions

View File

@@ -75,6 +75,15 @@ inserted.
A common idiom in Sprig templates is to uses `pluck... | first` to get the first
matching key out of a collection of dictionaries.
## merge
Merge two dictionaries into one, giving precedence to the dest dictionary:
```
$newdict := merge $dest $source
```
This is a deep merge operation.
## keys

View File

@@ -0,0 +1,11 @@
# Flow Control Functions
## fail
Unconditionally returns an empty `string` and an `error` with the specified
text. This is useful in scenarios where other conditionals have determined that
template rendering should fail.
```
fail "Please accept the end user license agreement"
```

View File

@@ -2,21 +2,22 @@
The Sprig library provides over 70 template functions for Go's template language.
- [String Functions](strings.html): `trim`, `wrap`, `randAlpha`, `plural`, etc.
- [String List Functions](string_slice.html): `splitList`, `sortAlpha`, etc.
- [Math Functions](math.html): `add`, `max`, `mul`, etc.
- [Integer Slice Functions](integer_slice.html): `until`, `untilStep`
- [Date Functions](date.html): `now`, `date`, etc.
- [Defaults Functions](defaults.html): `default`, `empty`, `coalesce`
- [Encoding Functions](encoding.html): `b64enc`, `b64dec`, etc.
- [Lists and List Functions](lists.html): `list`, `first`, `uniq`, etc.
- [Dictionaries and Dict Functions](dicts.html): `dict`, `hasKey`, `pluck`, etc.
- [Type Conversion Functions](conversion.html): `atoi`, `int64`, `toString`, etc.
- [File Path Functions](paths.html): `base`, `dir`, `ext`, `clean`, `isAbs`
- [String Functions](strings.md): `trim`, `wrap`, `randAlpha`, `plural`, etc.
- [String List Functions](string_slice.md): `splitList`, `sortAlpha`, etc.
- [Math Functions](math.md): `add`, `max`, `mul`, etc.
- [Integer Slice Functions](integer_slice.md): `until`, `untilStep`
- [Date Functions](date.md): `now`, `date`, etc.
- [Defaults Functions](defaults.md): `default`, `empty`, `coalesce`
- [Encoding Functions](encoding.md): `b64enc`, `b64dec`, etc.
- [Lists and List Functions](lists.md): `list`, `first`, `uniq`, etc.
- [Dictionaries and Dict Functions](dicts.md): `dict`, `hasKey`, `pluck`, etc.
- [Type Conversion Functions](conversion.md): `atoi`, `int64`, `toString`, etc.
- [File Path Functions](paths.md): `base`, `dir`, `ext`, `clean`, `isAbs`
- [Flow Control Functions](flow_control.md): `fail`
- Advanced Functions
- [UUID Functions](uuid.html): `uuidv4`
- [OS Functions](os.html): `env`, `expandenv`
- [Version Comparison Functions](semver.html): `semver`, `semverCompare`
- [Reflection](reflection.html): `typeOf`, `kindIs`, `typeIsLike`, etc.
- [Cryptographic and Security Functions](crypto.html): `derivePassword`, `sha256sum`, `genPrivateKey`
- [UUID Functions](uuid.md): `uuidv4`
- [OS Functions](os.md): `env`, `expandenv`
- [Version Comparison Functions](semver.md): `semver`, `semverCompare`
- [Reflection](reflection.md): `typeOf`, `kindIs`, `typeIsLike`, etc.
- [Cryptographic and Security Functions](crypto.md): `derivePassword`, `sha256sum`, `genPrivateKey`

View File

@@ -278,6 +278,43 @@ rules. And `0` is considered a plural because the English language treats it
as such (`zero anchovies`). The Sprig developers are working on a solution for
better internationalization.
## snakecase
Convert string from camelCase to snake_case.
Introduced in 2.12.0.
```
snakecase "FirstName"
```
This above will produce `first_name`.
## camelcase
Convert string from snake_case to CamelCase
Introduced in 2.12.0.
```
camelcase "http_server"
```
This above will produce `HttpServer`.
## shuffle
Shuffle a string.
Introduced in 2.12.0.
```
shuffle "hello"
```
The above will randomize the letters in `hello`, perhaps producing `oelhl`.
## See Also...
The [Conversion Functions](conversion.html) contain functions for converting