alonrbar/easy-template-x

The generated docx file don't remove lines if the text is not supposed to be shown

Closed this issue ยท 1 comments

srz09 commented

Hello ๐Ÿ‘‹

Here is the docx template content I'm using

template

and here is the generated one.

generated

As you can see there is a lot of empty space where the table was expected to be rendered (if the condition was true).

I was thinking that setting the condition to false would have automatically remove all the empty lines.

Is there a way to remove those empty lines ?

Thanks a lot and well done for this lib ๐Ÿ‘

Hi, looks like you just need to adjust the position of your condition tags. Instead of doing this:

Hello

{# condition}
Table
{/condition}

Rest of the text

Consider the following:

Hello
{# condition}

Table

{/condition}
Rest of the text

You can even go for this:

Hello
{# condition}
Table
{/condition}Rest of the text

Try to play with it a little until you find what's working for you exactly (I sometimes also play with the line height for fine tuning).