Closed SZaidAhmed closed 1 year ago
Hello @SZaidAhmed ,
What I would do would be to use "${{" and "}}" for the delimiters.
This way you could use : "}" in your template without any issue.
I will not add an option to ignore some kind of errors in the template, docxtemplater is quite strict, and by changing the delimiters, it will make it possible to use "}" in your template.
However, if a person writes : "Hello user}", then I want to warn users that the template is most probably invalid, I'm not going to add an option for it.
I don't want to add an obscure option to docxtemplater to handle this case.
If you really need this, you can fork docxtemplater and use following patch, it seems that it works for basic cases but I can't guarantee anything :
diff --git a/es6/lexer.js b/es6/lexer.js
index 44088bcf..a8714fe0 100644
--- a/es6/lexer.js
+++ b/es6/lexer.js
@@ -244,10 +244,13 @@ function getAllDelimiterIndexes(fullText, delimiters) {
case DELIMITER_NONE:
return indexes;
case DELIMITER_END:
- insideTag = false;
offset = endOffset;
position = "end";
len = end.length;
+ if (!insideTag) {
+ continue;
+ }
+ insideTag = false;
break;
case DELIMITER_START:
insideTag = true;
my full code is below what i want to do is either i can define two delimeters or i want to ignore the unopened tag error because my input file contains some words that end with "}" but starts with "$}" as i defined in delimeter