Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigation expressions not working? #72

Open
asmaier opened this issue May 24, 2024 · 4 comments
Open

Navigation expressions not working? #72

asmaier opened this issue May 24, 2024 · 4 comments

Comments

@asmaier
Copy link

asmaier commented May 24, 2024

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 ?

simple_template.xlsx
simple.json
simple.xlsx

@zapov
Copy link
Member

zapov commented May 24, 2024

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

@asmaier
Copy link
Author

asmaier commented May 24, 2024

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.

@zapov
Copy link
Member

zapov commented May 28, 2024

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.

@asmaier
Copy link
Author

asmaier commented May 28, 2024

Ok, I will do that. Nevertheless here is a pull request #73 to add navigation expressions in the templater-json jar. Maybe this is useful for anyone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants