All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
-
It is now possible to use Jinja2 expressions for selecting the nodes to process in a transformation. Until now only JSONPath was possible. With Jinja2 expression and the ability to use JavaScript filters it is now possible to select nodes in ways that were not possible with a JSONPath (e.g. only odd/even nodes, comparison with arbitrary injected values ,etc.) or to transform the selection:
transformations: - data: - data.yaml template: template.j2 nodes: # take all strings in the "nodes" array and prefix them # with the string "test-" expression: "data.nodes | prefix('test-')" type: jinja2 outputPath: '{{ node }}.txt'
-
The Maven plugin now has a standalone goal, so you can invoke SimpleGen via Maven without a
pom.xml
file. This is useful for example when you want to use SimpleGen in a CI/CD pipeline. The standalone goal is calledsimplegen:generateStandalone
and can be invoked like this:mvn com.ancientlightstudios:simplegen-maven-plugin:5.1.0:generateStandalone
By default, this looks for a
config.yml
in the current folder. You can override configuration settings using system properties, e.g.:mvn com.ancientlightstudios:simplegen-maven-plugin:5.1.0:generateStandalone \ # name of the configuration file (default: config.yml) -Dsimplegen.configFileName=myconfig.yml \ # path to the source folder (default: .) -Dsimplegen.sourceDirectory=/path/to/source \ # path to the output folder (default: .) -Dsimplegen.outputDirectory=/path/to/output \ # whether to re-generate files that have no changed input (default: false) -Dsimplegen.forceUpdate=true
- SimplegGen now gives better error/warning messages for a variety of cases.
- Breaking change: The HTML parser no longer tries to merge parsed HTML files as this doesn't make sense for HTML files. Instead, it will return a list of parsed HTML files. This is a breaking change because the output of the HTML parser is now a list instead of a single object.
- The HTML parser can now add the nested HTML subtree to the parsed data under the
@nestedHtml
property. This is useful if you want to get the full text of an HTML element including all nested elements. This is disabled by default and can be enabled by setting theextractNestedHtml
option totrue
.
- Fixed a dependency issue that caused the Maven plugin to fail in SimpleGen 4.0.0.
- Added support for parsing HTML files.
- Breaking change: The
resultPath
configuration option of the CSV parsing module has moved up one level and is now available for all data formats. This allows you to control where parsed data is mounted in the data tree:# before data: - includes: some_data.csv mimeType: text/csv parserSettings: resultPath: some_data # after data: - includes: some_data.csv mimeType: text/csv resultPath: some_data
- Fixed a problem where the template engine could not load error messages when being run in the Maven plugin. This would lead to a less than helpful error message when a template error occurred.
- The CSV extension now supports the
text/csv
mime type as well.
- The CSV extension now is also included with the Maven plugin.
- If the CSV contains an UTF-8 byte order mark (BOM), it is now automatically removed instead of breaking the first CSV header. You can disable this behavior by setting
stripBom
tofalse
in the configuration.
- You can now use CSV as an input data format. Note: Due to a packaging error this was not included with the Maven plugin in 3.1.0. Please use 3.1.1 instead.
- The Maven plugin now supports generating test sources. See the README for details (fixes #44).
- When a data file include definition yields no results, this will be printed as a warning. This is preferable to the previous behaviour where this was just silently ignored.
- When referring to data with a simple relative path that is outside the base directory, the path is now correctly resolved.
transformations:
- data:
# this is now correctly parsed
- ../data/data.yaml
- SimpleGen will no longer crash when a JavaScript error has no detailed information.
- When the
nodes
property is missing or invalid, a more helpful error message is now printed. (fixes #32).
-
You can now specify inline data directly in
config.yml
. This is useful if you use multi-stage code generation (e.g. generate aconfig.yml
and then run SimpleGen on the generated configuration) or if you just have a simple generation need and don't want to use extra data files to have all generation settings in one place.transformations: - data: - inline: this: is inline: data it: - can - be - arbitrarily - nested: yaml
Note that inline data always needs to be a map. Inline data can be mixed with all other data input, so you can mix it with YAML files, TOML files or XML files.
-
Breaking Change: You can now configure nested interpretation in the template engine. With nested interpretation the template engine will re-evaluate the result of an expression until there is no more Jinja code in it.
{% macro build_expression(value) %} {{ '{{' }}{{ value }}{{ '}}'}} {% endmacro %} {# we print #} -- {{ build_expression( 'test' ) }} -- {# with nested interpretation off this yields: #} -- {{ test }} -- {# with nested interpretation on, the {{ test }} will be re-evaluated again. Because no test variable is defined, this will yield: #} -- --
You can configure nested interpolation in
config.yaml
in the template engine settings:templateEngine: # if true, expressions that yield jinja template code will be re-interpreted # until no more jinja template code is in them. Use with care. # default false nestedInterpretationEnabled: true
Before this setting was introduced, this was always enabled. I chose to disable it by default because it has a lot of sometimes puzzling side-effects and it has security implications if you run the code generator on input you do not have under control.
- Updated various library dependencies to mitigate security issues.
- Fixed a parse error when parsing TOML files having quotes in their string values.
- Updated the
jackson
andant
dependencies to mitigate security issues.
- SimpleGen now allows for providing data in different formats than YAML. To do so, specify the mime type of the data format you are using in your data section like this:
If you leave out the mime type, SimpleGen will use YAML as the default. You can now use TOML and XML files to provide data for SimpleGen.
- data: - includes: "**/*.toml" mimeType: application/toml
- There is now an API available for extending SimpleGen. For now this API only allows you to write parsers for custom data formats.
- A new built-in filter for accessing environment variables named
env
is now available. You can use it like this:{{ 'HOME' | env }}
- Updated the project to Kotlin 1.4
- Replaced Spek testing framework with Kotest as Kotest seems to be a lot more mature. This also fixed that the tests were not running in then Maven build when using Spek.
- Fixed a packaging error for the maven plugin and standalone jar that would prevent custom javascript filters from working when they used the
Regex
class.
- Updated
ant
andguava
dependencies to mitigate security issues.
- Due to the migration to GraalVM there is now a
console.log
command available inside the JavaScript filters which can be used to output debug information (#19)
- Breaking Change: SimpleGen now uses GraalVM instead of Nashorn for evaluating custom script filters (#18). For most filters this should be a drop-in-replacement however some filters may not work anymore. See the Nashorn Migration Guide for details. Nashorn compatibility mode is enabled.
- Breaking Change: The second argument for script filters is no longer an instance of
com.hubspot.jinjava.interpret.JinjavaInterpreter
but rather a function which allows you to resolve template variables:// old function myFilter(input, interpreter, args) { var templateVariable = interpreter.context['variableName']; } // new function myFilter(input, resolve, args) { var templateVariable = resolve('variableName'); }
- Updated
jackson
libraries to mitigate various CVEs. - Updated
jinjava
library to mitigate CVE-2018-18893.
- Incremental code generation (#14)
- Better error messages on missing files (#2, #7)
- Better support for multiple functions in a single script file (#17)
- Updated documentation for the new features.
- JavaScript function names no longer need to be lower case (#8)
- JavaScript filters now can return null values
- Support for custom JavaScript filters
- It is now possible to configure template engine.
- Initial public release