ngs-doo / TemplaterExamples

Creating reports in .NET and Java
https://templater.info
The Unlicense
48 stars 27 forks source link

Collection per page rendering issue #61

Closed phinc closed 1 year ago

phinc commented 1 year ago

Templater gives an unexpected result for the following docx template Page per entry test: {{collection.name}} {{collection.value}} {{collection.values.id}} and json input { "collection": [ { "name" : "one", "value": "value one", "values": [{"id": "value one nested array1"}, {"id": "value one nested array2"}] },{ "name" : "two", "value": "value two", "values": [{"id": "value two nested array1"}, {"id": "value two nested array2"}] },{ "name" : "three", "value": "value three", "values": [{"id": "value three nested array1"}, {"id": "value three nested array2"}] },{ "name" : "four", "value": "value four", "values": [{"id": "value four nested array1"}] } ] } Expectation for the output file is to get a page per each collection.values.id in a parent context that is totally 7 pages. The real output has 10 pages and context is mixed. For instance, 'value one nested array2' is output in a context of item 'two'. TBDGS-46.zip

zapov commented 1 year ago

Tnx for the report, I'll take a look. Off first hand I think its tricky to work with it in such a way where you have no boundaries, as Templater might pick entire page/document for some case where its not really expected.

But yeah, I agree that ideally it should produce 7 page.

zapov commented 1 year ago

I've looked and this and agree that it should behave better. Will look into improving this case now so it works out-of-the box for next version.

It does behave better if you help it out and give it some boundaries (like I did in the changed attachment: PagePerCollectionEntry_WithSections.docx ) But this does have a bad side-effect of having first and last page empty.

phinc commented 1 year ago

Thank you, it works

zapov commented 1 year ago

Templater v7.2.1 has been released which fixes this issue