Coder Social home page Coder Social logo

Comments (2)

edi9999 avatar edi9999 commented on September 26, 2024

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.

from docxtemplater.

edi9999 avatar edi9999 commented on September 26, 2024

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;

from docxtemplater.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.