carboneio / carbone

Fast and simple report generator, from JSON to pdf, xslx, docx, odt...
https://carbone.io
Other
1.33k stars 196 forks source link

[Bug Report]: Incorrect repetition with filtered array when inserting other values #128

Open Toffaa opened 3 years ago

Toffaa commented 3 years ago

Hi, I'm having an issue with filtered array repetition. When I insert a value which is not from the array, Carbone will make copies of the template a number of time equal of size of the unfiltered array, without displaying data. Please see the example below which I hope to be clearer.

Note that using {d.cars[brand="Toyota", i]..test} solve the problem, so maybe that's my use of Carbone that is wrong, but this would need to be documented if so.

Environment Carbone Version: 3.x.x (Studio)

Data: { "test": "value", "cars": [ {"brand": "Lumeneo","power": 2}, {"brand": "Tesla","power": 3}, {"brand": "Toyota","power": 1}, {"brand": "Toyota","power": 4} ] }

Template: Power :{d.cars[brand="Toyota", i].power} Test : {d.test} {d.cars[brand="Toyota", i+1].power}

Expected Behaviour

Power :1 Test : value Power :4 Test : value

Actual Behaviour

Power : Test : value Power : Test : value Power :1 Test : value Power :4 Test : value

steevepay commented 3 years ago

Hello @Toffaa, thank you for reporting the issue. I reproduced the error and we are going to look at it. I come back to you when the fix is available. Have a great day!