docx-templates icon indicating copy to clipboard operation
docx-templates copied to clipboard

Nested IFs in a table cell issue

Open ArtVS opened this issue 9 months ago • 3 comments

Hi, everyone! I have the following nested IF statement in a table cell my template: {IF $parameter.isMain == 0}{*ParameterName}{IF $parameter.unit != null}, {*ParameterUnit}{END-IF}{END-IF}{IF $parameter.isMain != 0}**{*ParameterName}{IF $parameter.unit != null}, {*ParameterUnit}{END-IF}**{END-IF}

It displays main parameter in bold and non-main parameters in regular, and should a parameter have a unit, it is displayed too.

Since version 11.5 the createReport function errors, saying nested IFs are not allowed. Is there a workaround other than rewriting without nested IFs? Or can someone add a fix for that issue in future versions, maybe?

ArtVS avatar May 06 '24 12:05 ArtVS

I have the exact same issue; templates working with previous versions now throw this error

Invalid IF command nested into another IF command on the same table row

Would like to understand what changed since I cannot find an explanation in the Changelog

raffaele-clevermind avatar Jun 24 '24 08:06 raffaele-clevermind

I think this is due to the fix we merged for the infinite loop bug described in #340. Can you post a simple reproduction?

jjhbw avatar Jul 04 '24 13:07 jjhbw

Also have this same issue, with multiple IF

image

tentone avatar Jul 10 '24 11:07 tentone

I have the same problem. After update #340 , a lot of my documents cannot be generated! like:

{{IF $i.result.includes('xxx')}}
{{FOR user IN $i.users}}
{{IF $user.status === true}}
{{ $user.username }}:{{$user.age}}({{userpoint.sex}})
{{END-IF}}
{{END-FOR user}}
{{END-IF}}

output:

Error: Invalid IF command nested into another IF command on the same table row: IF $user.status === true: 'undefined'

xymfs avatar Nov 08 '24 04:11 xymfs