Navigation expressions not working?
I have the following simple.json file:
{
"colors": [
{"name": "red"},
{"name": "green"},
{"name": "blue"}
]
}
and a simple_template.xlsx with expressions like
{{atColor = colors:at(1)}}
My favorite color is {{atColor.name}}.
[[colors.name]]
[[colors:at(0).name]]
[[colors:top(2).name]]
I run it like java -jar templater-json.jar simple_template.xlsx simple.json simple.xlsx
But in the output simple.xlsx I can only see that [[colors.name]] gets replaced:
{{atColor = colors:at(1)}}
My favorite color is {{atColor.name}}.
red
green
blue
[[colors:at(0).name]]
[[colors:top(2).name]]
It seems like all the navigation expressions are ignored. Am I doing something wrong here? Or are navigation expressions not supported by templater-json.jar ?
As far as I see its not configured: https://github.com/ngs-doo/TemplaterExamples/blob/master/Intermediate/TemplaterJson/src/main/java/hr/ngs/templater/json/TemplaterJson.java#L78 So you can configure it and recompile your version
Would it be much effort to add .navigateSeparator(':', null) to the configuration builder of the templater-json.java and then release a new version 8.0.1 for everyone? I think it is confusing that the documentation says
"There are two built-in navigation plugins. .. at(INDEX)...top(COUNT)",
but these are not activated by default. It took me quite some digging in the documentation to see that
"Navigation plugins are disabled by default, but can be enabled if metadata separator is defined"
and that this also must be done to activate the build-in navigation plugins. The Getting started section of the documentation also seems to imply that navigation expressions are enabled by default, so I might not be the only one to stumble over this when using the command line tool templater-json.java.
Eh, it also says just before
To enable navigation expressions, first navigation metadata must be defined
While most of the examples are using : a lot of customers have their own versions such as / or | or similar. I think for now it would be easier for your to build your own version which behaves as you expect it to.
Ok, I will do that. Nevertheless here is a pull request https://github.com/ngs-doo/TemplaterExamples/pull/73 to add navigation expressions in the templater-json jar. Maybe this is useful for anyone.