ngs-doo / TemplaterExamples

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

Default tag not repeating with template using :page #39

Closed DanielWalter-MXP closed 3 years ago

DanielWalter-MXP commented 3 years ago

Hello. We have a data structure like this one:

{
  [ MyCompany: {
      [ Name: string,
        Address: string
       ]},
    Fiscal: List({
      [ Number: int,
       TotalValue: decimal,
       Item: List({
               [ Code: string,
                 Value: decimal
                ]})
      ]})
]}

If creating a model where there is multiple Fiscal and just one MyCompany the tags inside MyCompany doesn't repeat in the rest of the report.

Attached are the example, result and desired result. Example

Result generated

Result desired

zapov commented 3 years ago

Can you please upload JSON used for this example data?

DanielWalter-MXP commented 3 years ago

Yes, of course.

Example.txt

zapov commented 3 years ago

The output I get looks kind of like what you expect? I did had to fix template a bit since your "tags" are not really valid. And maybe putting page metadata at the correct place fixed the problem?

example.docx

templater-output.docx

DanielWalter-MXP commented 3 years ago

Here it is the json model with the data I found the issue (maybe it has to do with the size?) and the template used jsonExample.txt Template-Example.docx

zapov commented 3 years ago

Hm, I'll look next week what can be done about this.

You have a problem with your template (one of the tag is wrong) - this is easily reported by Templater Editor, might be worth upgrading your license as you also get debugging support with it.

You can work around this problem for now by changing input JSON a bit (putting Minha section before NotaFiscal). And you don't need :page metadata on all those tags, just first one will suffice

zapov commented 3 years ago

There is also one more workaround. You don't need to reorder JSON, but instead of passing a collection, just pass the single element from the collection. It works as expected in that case.

zapov commented 3 years ago

This should now work out of the box. You can download the latest snapshot from here

btw. this :page metadata is something old which should really be deprecated. It will work only for simple use cases. It would be better to put a tag outside of table with :hide metadata which would result in the same behavior

DanielWalter-MXP commented 3 years ago

Don't seem to have worked for me, but that could just be that I did something wrong to replace the file.

Considering that the :page metadata is deprecated I won't be pushing too into it and change the way the data is formulated to templater.

Edit: I tried using the :hide without the page on the regular version and while it did replicate, the tag [[MinhaEmpresa.RazaoSocial]] didn't replicate

zapov commented 3 years ago

The jsonExample.txt and Template-Example.docx should work out of the box with the snapshot I linked. The hide doesn't work on the regular version either. It will only work with workarounds (don't send a top level collection, just rather the object from it). Fix is mainly for that problem

DanielWalter-MXP commented 3 years ago

I have fixed the model to make more sense, thank you for your time and support.