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]: len() not working with filtered arrays #136

Open Toffaa opened 3 years ago

Toffaa commented 3 years ago

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

Steps to reproduce

Template:

Cars number: {d.cars:len()} Toyota number: {d.cars[brand="Toyota"]:len()}

Data:

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

Hello,

I'm not sure if that's a bug or not, but it would be great to be able to get the length of filtered arrays. In my exemple, the first :len() works properly, while the second displays nothing.

Thank you for your work ! Kind regards, Toffaa

steevepay commented 3 years ago

Hello @Toffaa, sorry for the delay. Get the length of a filtered array is not supported yet, we are working on a new aggregation system that will solve this issue. We will notify you when it's available. An alternative is to preprocess the length before, insert the value in your JSON dataset and call Carbone. Let me know if this alternative is enough for you.