You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- `includeAsString`: Similar to `include`, allows to register a template, but reads the template contents from a string instead of a file. E.g: `{{ includeAsString “templateName” .var_with_contents }}`
- `invoke`: Similar to `{{ template [name] [data] }}, invokes a template by a given name with a data object. The difference with `template` is that 'invoke` can be used with a string variable as the name instead of a hardcoded string.
- `parse`: Attempts to parse the provided template contents using the provided data object and returns the parsed value. Usage `{{ parse [obj] [template contents] }}`.
- `parseXpath`: Attempts to parse a value inside a data object as a template and returns the parsed value using the same entry object to parse the template. Usage `{{ parse [obj] [xpath to value with template] }}`
- `in`: Indicates whether a value is contained in an array. Usage: `{{ in [array] [value] }}`
Minor Fixes:
- The helper `yaml` now properly allows an optional argument to indicate the indentation of the resulting YAML. Usage `{{ yaml [obj] [int] }}` where the `int` number indicates the amount of spaces for indentation.
- Map functions now allow XPATH to be provided with or without a `.` as a prefix
_=h.Register("map", h.mapFn, "Creates a new map[string]interface{}, the provided arguments should be key, value, key, value...")
49
53
_=h.Register("dict", h.mapFn, "Creates a new map[string]interface{}, the provided arguments should be key, value, key, value...")
50
54
_=h.Register("include", h.includeFile, "Includes a template file as an internal template reference by the provided name")
55
+
_=h.Register("includeAsString", h.includeTemplate, "Includes a provided template string as an internal template reference by the provided name. Eg: {{ include [name] [contents] }}")
51
56
_=h.Register("set", h.setFn, "Allows to set a value to a map[string]interface{} or map[interface{}]interface{}")
52
57
_=h.Register("append", h.append, "Appends a value into an existing array")
53
58
_=h.Register("iterate", h.iterate, "Creates an iteration array of the provided length, so it can be used as {{ range $val := iterate N }} where N is the length of the iteration. Created due to the lack of `for` loops.")
_=h.Register("mapGet", h.mapGetFn, `Allows to get a value from a map using an XPATH representation of the key. Accepts optional argument for a default value to return if the value is not found". E.g: {{mapGet $map ".some.key.path" $someDefaultValue }}`)
57
62
_=h.Register("mapContains", h.mapContainsFn, `Indicates whether a value at the provided XPATH representation of the key exists in the provided map`)
58
63
_=h.Register("mapConvert", h.mapConvertFn, `Ensures the provided map is map[string]interface{}. Useful when loading values from a YAML where the deserialization is map[interface{}]interface{}`)
64
+
_=h.Register("invoke", h.invoke, `Similar to {{ template [name] [data] }}, invokes a name by the given name with the given data. The difference with 'template' is that 'invoke' can be used with a string value as the name instead of a hardcoded string`)
65
+
_=h.Register("parse", h.parse, `Attempts to parse the provided template contents using the provided data object and returns the parsed value. Usage {{ parse [obj] [template contents] }}`)
66
+
_=h.Register("parseXpath", h.parseXpath, `Attempts to parse a value inside a data object as a template and returns the parsed value using the same entry object to parse the template. Usage {{ parse [obj] [xpath to value with template] }}`)
67
+
_=h.Register("in", h.in, `Indicates whether a value is contained in an array. Usage: {{ in [array] [value] }}`)
0 commit comments