mirror of
https://github.com/Luzifer/korvike.git
synced 2024-12-20 19:21:17 +00:00
Add b64encode as a function
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
7b755d344a
commit
2fd0bf97a1
2 changed files with 15 additions and 0 deletions
|
@ -13,6 +13,12 @@
|
||||||
# echo "{{ .foo }}" | korvike -v foo=bar
|
# echo "{{ .foo }}" | korvike -v foo=bar
|
||||||
bar
|
bar
|
||||||
```
|
```
|
||||||
|
- `{{ b64encode <string> }}`
|
||||||
|
Encodes the string with base64 [StdEncoding](https://golang.org/pkg/encoding/base64/#pkg-variables)
|
||||||
|
```console
|
||||||
|
# echo '{{ b64encode "Hello World" }}' | korvike
|
||||||
|
SGVsbG8gV29ybGQ=
|
||||||
|
```
|
||||||
- `{{ env <variable name> [default value] }}`
|
- `{{ env <variable name> [default value] }}`
|
||||||
Read environment variables and replace them inside the template
|
Read environment variables and replace them inside the template
|
||||||
```bash
|
```bash
|
||||||
|
|
9
functions/func_base64.go
Normal file
9
functions/func_base64.go
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
package functions
|
||||||
|
|
||||||
|
import "encoding/base64"
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
registerFunction("b64encode", func(name string, v ...string) string {
|
||||||
|
return base64.StdEncoding.EncodeToString([]byte(name))
|
||||||
|
})
|
||||||
|
}
|
Loading…
Reference in a new issue