DOCX Templater

Generate .docx/.pptx files with dynamic content using .docx/.pptx templates

DOCX TEMPLATE

.docx/.pptx template used to generate files with dynamic content. Click on "PICK" to select the template file or use the %FILENAME% variable. Here's how to edit and compile a template file:

Text templates allow you to include variable names enclosed in percentage symbols, such as "%title%". These variables can be styled using text formatting in the template.

Array templates are defined using special delimiters, such as "%#arrayName%" to indicate the start of an array and "%/arrayName%" to indicate the end of the array. Within the array template, you can specify how each item in the array is formatted using text templates like "%keyName%" for each property of the array items. When inserting an array template into a document, rows, and sections will be automatically added based on the length of the array. If you want to introduce line breaks between items in the text, you can include line break syntax at the end of the array using the template tags.

Image templates are used to dynamically insert images into a document. To specify an image variable within a document template, you use the format "%img.variableName%" where "variableName" is the name of the image variable. The variable name should be preceded by "img". to indicate that it's an image variable. For example, %img.chart1%.

Input Object

Each key in the input object is the name of a .txt file in the working folder (excluding the file extension), and each value is the text content of the file.

// //Read the value of 'title.txt' and 'products.txt' in the workspace
let title = input['title']
console.log('title:', title)

let products = JSON.parse(input['products'])
console.log('products:', products)

output Object

Object to correspond to variables in a .docx or .pptx template file with the format "%key%". You must specify the value for the "key" variable within the output object as output['key']. If you are working with an array variable within a .docx template file with the format "%items%", you should make sure that output['items'] is an array containing the values you want to replace in the template.

// The .docx template file defines %title% and %#products% %name% %amount% %price% %/products%
output['title'] = title
output['products'] = products

// Insert the PNG file from the workspace
output['img.chart1'] = 'chart1.png'

--

We are dedicated to improving our content. Please let us know if you come across any errors, including spelling, grammar, or other mistakes, as your feedback is valuable to us! 🤖️⚡️

Last updated