Support limited variable interpolation.
Kong supports limited variable interpolation into help strings, enum lists and
default values.
Variables are in the form:
${<name>}
Variables are set with the `Vars(map[string]string)` option. Undefined
variable references in the grammar will result in an error at construction
time.
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package kong
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestInterpolate(t *testing.T) {
|
||||
vars := map[string]string{
|
||||
"name": "Bobby Brown",
|
||||
"age": "35",
|
||||
}
|
||||
actual, err := interpolate("${name} is ${age} years old", vars)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, `Bobby Brown is 35 years old`, actual)
|
||||
}
|
||||
Reference in New Issue
Block a user