1
0
Fork 0
mirror of https://github.com/Luzifer/korvike.git synced 2024-11-08 15:30:05 +00:00

Add b64encode as a function

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-05-31 12:50:34 +02:00
parent 7b755d344a
commit 2fd0bf97a1
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E
2 changed files with 15 additions and 0 deletions

View file

@ -13,6 +13,12 @@
# echo "{{ .foo }}" | korvike -v foo=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] }}`
Read environment variables and replace them inside the template
```bash

9
functions/func_base64.go Normal file
View 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))
})
}