template - line break of bash script is skipped

I am using the template module for a bash script

There is a problem with these lines

   cd $PGARCH
   {% raw %}while mapfile -t -n 20 ARCHIVE_LOGS && ((${#ARCHIVE_LOGS[@]})){% endraw %}
   do

they should be like below

   cd $PGARCH
   while mapfile -t -n 20 ARCHIVE_LOGS && ((${#ARCHIVE_LOGS[@]}))
   do

but factually the line break does not survive, hence the while loop, does not work

   cd $PGARCH
   while mapfile -t -n 20 ARCHIVE_LOGS && ((${#ARCHIVE_LOGS[@]}))do

I tried the change the .j2 to

   cd $PGARCH
   {% raw %}while mapfile -t -n 20 ARCHIVE_LOGS && ((${#ARCHIVE_LOGS[@]})){% endraw %}\n
   do

this prevent the line breack from disappearing but the '\n' remains in the target file on the remote

how would I approach this?

This works:

 **cd $PGARCH**  **{% raw -%}**  **while mapfile -t -n 20 ARCHIVE_LOGS && ((${#ARCHIVE_LOGS[@]}))**  **{% endraw %}**  **do**

Or, if you had other Jinja variables to expand in that line, you could rewrite

 **${#ARCHIVE_LOGS[@]}**

spot on, thanks.