mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-11 14:39:28 +02:00
docs: improve tmpl.map
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
parent
24347358e9
commit
d5a81df6c5
@ -96,6 +96,9 @@ func TestWithArtifact(t *testing.T) {
|
||||
|
||||
"remove this": "{{ filter .Env.MULTILINE \".*remove.*\" }}",
|
||||
"something with\nmultiple lines\nto test things": "{{ reverseFilter .Env.MULTILINE \".*remove.*\" }}",
|
||||
|
||||
// maps
|
||||
"123": `{{ $m := map "a" "1" "b" "2" }}{{ index $m "a" }}{{ indexOrDefault $m "b" "10" }}{{ indexOrDefault $m "c" "3" }}{{ index $m "z" }}`,
|
||||
} {
|
||||
tmpl := tmpl
|
||||
expect := expect
|
||||
@ -423,12 +426,7 @@ func TestMdv2Escape(t *testing.T) {
|
||||
mdv2Escape("aaa_*[]()~`>#+-=|{}.!"))
|
||||
}
|
||||
|
||||
func TestMap(t *testing.T) {
|
||||
ctx := testctx.New()
|
||||
out, err := New(ctx).Apply(`{{ $m := map "a" "1" "b" "2" }}{{ index $m "a" }}{{ indexOrDefault $m "b" "1" }}{{ indexOrDefault $m "c" "3" }}{{ index $m "z" }}`)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "123", out)
|
||||
|
||||
_, err = New(ctx).Apply(`{{ $m := map "a" }}`)
|
||||
func TestInvalidMap(t *testing.T) {
|
||||
_, err := New(testctx.New()).Apply(`{{ $m := map "a" }}`)
|
||||
require.ErrorContains(t, err, "map expects even number of arguments, got 1")
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ On all fields, you have these available functions:
|
||||
| `title "foo"` | "titlenize" the string using english as language. See [Title](https://pkg.go.dev/golang.org/x/text/cases#Title). Since v1.14 |
|
||||
| `mdv2escape "foo"` | escape characters according to MarkdownV2, especially useful in the Telegram integration. Since v1.19 |
|
||||
| `envOrDefault "NAME" "value"` | either gets the value of the given environment variable, or the given default. Since v1.19 |
|
||||
| `$m := map "KEY" "VALUE"` | creates a map from a list of key and value pairs. Since v1.21 |
|
||||
| `$m := map "KEY" "VALUE"` | creates a map from a list of key and value pairs. Both keys and values must be of type `string`. Since v1.21 |
|
||||
| `indexOrDefault $m "KEY" "value"` | either gets the value of the given key or the given default value from the given map. Since v1.21 |
|
||||
|
||||
With all those fields, you may be able to compose the name of your artifacts
|
||||
|
Loading…
x
Reference in New Issue
Block a user