Releases: jucardi/infuse
Releases · jucardi/infuse
v1.0.12
v1.0.12
New Helpers:
includeAsString
: Similar toinclude
, 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
templateis 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 theint
number indicates the amount of spaces for indentation. - Map functions now allow XPATH to be provided with or without a
.
as a prefix
v1.0.11
- Minor fix to the 'set' helper so it allows
map[interface{}]interface{}
as well asmap[string]interface{}
. - Added support for arm64 targets for all supported OS (Windows, MacOS, Linux)
- Added
stringsSub
helper to obtain the substring of a string - Added new map helpers to allow XPATH notation to be used to get or set values
v1.0.10
v1.0.9
v1.0.8
New features:
- Implemented support for directory templates. Now a directory can be specified as the source, and another directory as the destination. All files within the source directory will be treated as template files and will be parsed with the source data using the same filenames as the target. This is done recursively, so subdirectories can also be used. See https://github.com/jucardi/ms-sample for an example on directory templates.
Compatibility Updates
- Initialized Go Modules
- Added vendor directory for dependencies
New String conversion handlers
-
Introduced new handlers for String conversion:
stringxCamelToDash
> Converts a camelCase string to a dash-separated stringstringxCamelToSnake
> Converts a camelCase string to a snake_case stringstringxDashToCamel
> Converts a dash-separated string to a camelCase stringstringxDashToPascal
> Converts a dash-separated string to a PascalCase stringstringxPascalToDash
> Converts a PascalCase string to a dash-separated stringstringxPascalToSnake
> Converts a PascalCase string to a snake_case stringstringxSnakeToCamel
> Converts a SnakeToCamel string to a camelCase stringstringxSnakeToPascal
> Converts a SnakeToCamel string to a PascalCase string
-
Changed the behavior of
title
, it now properly converts a provided string to a title case, capitalizing the first letter of every word in a text, and ensuring the rest of the characters in the word are lowercase -
Added short alias
lower
forlowercase
-
Added short alias
upper
foruppercase
stringsJoin now allows any type of array
Replaced the stringsJoin
handler to be a custom function that will allow an array instead of only []string
, and will attempt to convert all members to string
, so the resulting string array will be passed to strings.Join
New helpers added
- indent: Indents a given string using the provided indentation. Eg:
{{ indent "somestring with line breaks" " " }}
- loadJson: Unmarshals a JSON string into a
map[string]interface{}
. Eg:{{ $obj := loadJson "{\"someKey\": 1234}" }}
- mathAdd: Adds all the provided numbers together and returns the result
- mathMult: Multiplies all the provided numbers together and returns the result
Added `iterate` helper
Added iterate
helper for Go Templates since there is no for
loop.
Usage:
{{ range $val := iterate N }}
Where N
is the length of the iteration
Added 'append' helper
- Added 'append' helper to easily append values to arrays within templates