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

Features request: ELSE statement and comments

Open amunhoz opened this issue 4 years ago • 3 comments

First, great work! This has been very useful. There are two features i'm missing to use it in a better way, like: • option to use ELSE with IF stament • tag for comments, wich disapper after the report generation

Thanks

amunhoz avatar May 18 '20 13:05 amunhoz

Can you explain what you mean with the 'tag for comments' exactly? I'm afraid i dont understand.

jjhbw avatar May 18 '20 14:05 jjhbw

I take that to mean comments to explain the document logic, but that can be done with standard js comments ## ! // some comment ## .I could be interpreting incorrectly though. Having ELSE option would be nice, for sure

KAVA-Leigh avatar May 18 '20 21:05 KAVA-Leigh

I agreed about the ELSE statement (or a switch) which could allow a significant time gain for generation Example loop on hundred elements and having each condition are mutually exclusive (and in my case the most common is the first one) --> on each iteration the 3 conditions are evaluated which produce a lot of gapping time (in a concrete example it takes a little 2min for generate a document with these 3 conditions and about 45sec if I remove it and always do rendering case 1)

+++FOR controle IN $fiche.controles+++
	+++IF $controle.enregistrement === `case 1`+++
		rendering element for case 1
	+++END-IF+++
	+++IF $controle.enregistrement === `case 2`+++
		rendering element for case 2
	+++END-IF+++
	+++IF $controle.enregistrement === `case 3`+++
		rendering element for case 3
	+++END-IF+++
+++END-FOR controle +++

Triskell2k1 avatar Apr 08 '21 15:04 Triskell2k1