I am getting stated using DocxTemplater with Node.
I am trying to figure out how to remove an empty line if the element is empty (i.e '' or null) - I can't seem to find a similar case on SO or elsewhere!
My Placeholders on the Docx look like this:
{#data}
{#input}
{Line1}
{Line2}
{Line3}
{/input}
{/data}
Any my Array looks like this:
data: {
input: {
Line1: 'TEXT1',
Line2: '',
Line3: 'TEXT3'
},
}
When I create a document I would like to remove the line in which 'Line2' is as its empty.
So instead of this:
TEXT1
TEXT3
I would like
TEXT1
TEXT3
UPDATE
Changed my code to the below as per the advice, however haven't had any success. Any more pointers? Thanks in advance!
{#data}
{#input}
{#Line1}{Line1}{/Line1}
{#hasLine2}{Line2}{/hasLine2}
{#Line3}{Line3}{/Line3}
{/input}
{/data}
And
data: {
input: {
Line1: 'TEXT1',
Line2: '',
Line3: 'TEXT3',
hasLine2: false
},
}