docx-templates
docx-templates copied to clipboard
Nested IFs in a table cell issue
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?
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
I think this is due to the fix we merged for the infinite loop bug described in #340. Can you post a simple reproduction?
Also have this same issue, with multiple IF
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'