Giter Club home page Giter Club logo

Comments (7)

edi9999 avatar edi9999 commented on August 15, 2024

Hi,

why exactly would you like to use templates inside templates ? Are you using that many templates that you would like to use subcomponents that could be used in many different templates ?

An other question: If I understood correclty, you would like to have exactly this syntax:

var doc = new DocxGen().loadFromFile("xmlInsertionExample.docx");
var doc2 = new DocxGen().loadFromFile("littleTextBlock.docx");
doc.setTags({
    tag1: "Hello World",
    rawXmlTag: doc2.getDocumentBody()
});

Or was that code just to tell an idea on how to implement it ?

So except for the getDocumentBody() method they wouldn't be so much to implement.

I need some time to think about it but if it's just that function I think it would be ok.

from docxtemplater.

alexcrack avatar alexcrack commented on August 15, 2024

The reason is I need to insert some formatted text into template. And that text would be typed by manager in another document, for example.

Or was that code just to tell an idea on how to implement it ?

Yes, you understood correctly. This is an idea. I would happy to use any possibility to solve my task.

Thank you.

from docxtemplater.

edi9999 avatar edi9999 commented on August 15, 2024

Since v0.5.1, you can do the following:

var doc = new DocxGen().loadFromFile("xmlInsertionExample.docx");
var doc2 = new DocxGen().loadFromFile("littleTextBlock.docx");
path="word/document.xml"
bodyData=doc2.zip.files[path].asText()
body=(new XmlTemplater(bodyData)).getFullText('w:body')
doc.setTags({
    tag1: "Hello World",
    rawXmlTag: body
});

I have not tested this but I think it should work. Be informed that this is kind of a 'hack' around the library, as XmlTemplater shouldn't be accessible to the end-users and will be in later versions removed from the global scope.

from docxtemplater.

alexcrack avatar alexcrack commented on August 15, 2024

Thank you. It works.
But if I put {@rawXmlTag} in the table cell it is error occured:

/mnt/work/node_modules/docxtemplater/js/docxgen.js:8
aractersAdded[n]]!==a[0][0])throw"no < at the beginning of "+a[0][0]+" (2)";if
                                                                    ^
no < at the beginning of < (2)

UPD
hmm
error occurs this way:

+-------------------------+-------------------------+
|  {@rawXmlTag}           |   Something             |
+-------------------------+-------------------------+

But if the rest table cells are emty it works without errors:

+-------------------------+-------------------------+
|  {@rawXmlTag}           |                         |
+-------------------------+-------------------------+

from docxtemplater.

edi9999 avatar edi9999 commented on August 15, 2024

Oh right. You're probably having tags after the {@rawXmlTag} and this causes the issue...

from docxtemplater.

edi9999 avatar edi9999 commented on August 15, 2024

I've reproduced the bug in a new branch, i will let you know when it is fixed.

from docxtemplater.

edi9999 avatar edi9999 commented on August 15, 2024

Fixed since v0.5.2

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.