Comments (7)
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.
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.
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.
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.
Oh right. You're probably having tags after the {@rawXmlTag} and this causes the issue...
from docxtemplater.
I've reproduced the bug in a new branch, i will let you know when it is fixed.
from docxtemplater.
Fixed since v0.5.2
from docxtemplater.
Related Issues (20)
- Differentiate between conditions and loops when getting tags HOT 1
- Conditional assignment doesn't work as expected HOT 1
- Page break propogates to all elements inside div HOT 5
- Numbering for conditional text HOT 3
- Question: Importing ExpressionParser in TypeScript. HOT 6
- When I write a tag in complex content, it doesn't work HOT 4
- HTMLModule Dependencies causing errors HOT 1
- paragraphLoop doesn't seem to work HOT 2
- ChartModule + ErrorLocationModule HOT 2
- Bun.sh HOT 1
- Trying to setup angular parser, but is failing with compilation error. HOT 8
- getSize 返回一个promsie ,word预览正常,但是导出word图片丢失 HOT 2
- Compile (tsx) issue with TxtTemplater HOT 1
- Ability to Insert IDs into XML Tags HOT 1
- Slides demo is broken HOT 1
- According to Microsoft Word, the generated file is corrupted. Cannot open it. HOT 12
- Duplicate content of a word file (in one page) HOT 1
- Error: New Delimiters cannot be parsed HOT 2
- Conditional vertical table HOT 1
- setting variable from object HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docxtemplater.