guigrpa/docx-templates

JS with custom delimiter

KAVA-Leigh opened this issue · 2 comments

Hi there,

We are using custom delimiters ( ['{$', '}'] ) and this is where the issue lies - when trying to include JS snippets we have errors and this is only when using the closing curly as delimiter, which is obviously the same as JS closing brace.

Any suggestions for working around this, or do we need to choose a different closing delimiter?

i.e.

{$! 
   color = 'blue'; 
   resp = '';
   switch(color){
      case 'blue':
           resp = `the color is ${color}`;
           break;
      default:
           resp = 'no color chosen';
   }    // <-- this is being interpreted as closing delimiter, no EOF
}

This is a pointless operation, it is just a simplified example..

EDIT: We moved to a different delimiter set in order to resolve this issue '['{#,'#}']'.
It seems likely that there is no other resolution for the original issue, in which case it may be helpful to just include a warning in the documentation, perhaps ?

jjhbw commented

Thanks for the report! I'll do some digging. Probably best if we just update the docs to discourage this case for now.

jjhbw commented

Added a paragraph to the docs to try and prevent this. Thanks for bringing it up!