{"_id":"@bposman/docxtemplater","name":"@bposman/docxtemplater","dist-tags":{"latest":"2.1.6"},"versions":{"2.1.6":{"name":"@bposman/docxtemplater","version":"2.1.6","author":{"name":"Edgar Hipp"},"description":".docx generator working with templates and data (like Mustache)","contributors":[{"name":"Edgar Hipp"}],"main":"js/index.js","bin":{"docxtemplater":"js/cli.js"},"keywords":["docx","templates","generation","microsoft word"],"repository":{"type":"git","url":"git+https://github.com/bposman/docxtemplater.git"},"dependencies":{"pizzip":"^3.1.7","memoizejs":"^0.1.1"},"devDependencies":{"angular-expressions":"^0.3.0","babel-cli":"^6.6.5","babel-eslint":"^6.0.2","babel-preset-es2015":"^6.5.0","bluebird":"^3.3.4","browserify":"^13.0.0","chai":"^3.3.0","eslint":"^2.7.0","lodash":"^4.14.2","mkdirp":"^0.5.1","mocha":"^2.3.3","mustache":"^2.1.3","rimraf":"^2.5.3","uglify-js":"^3.17.4"},"license":"MIT","engines":{"node":">=0.10"},"scripts":{"prepublish":"rimraf build && mkdirp build && npm run compile && npm run browserify && npm run uglify","preversion":"npm test","compile":"npm run convertto:es5 && node examples/compile_site.js","browserify:test":"browserify --insert-global-vars __filename,__dirname -r ./js/tests/docxtemplater.js -s DocxtemplaterTest > browser/docxtemplaterTest.js","browserify:lib":"browserify --insert-global-vars __filename,__dirname -r ./js/docxtemplater.js -s Docxtemplater > build/docxtemplater.js","browserify:demo":"browserify --insert-global-vars __filename,__dirname -r ./examples/main.js -s Docxdemo > browser/main.min.js","uglify:lib":"uglifyjs build/docxtemplater.js > build/docxtemplater.min.js","uglify":"npm run uglify:lib","browserify":"npm run browserify:test && npm run browserify:lib && npm run browserify:demo","convertto:es5":"rimraf js -rf && mkdirp js && npm run babel","convertto:es5:watch":"npm run babel -- --watch","test:watch":"node watch_file_and_run_test.js & npm run convertto:es5:watch","lint":"eslint .","babel":"babel es6 --out-dir js","mocha":"mocha js/tests/docxtemplater.js","test:es6":"mocha es6/tests/docxtemplater.js","test":"npm run compile && npm run mocha","test:es5":"npm test"},"gitHead":"622bcee4ddbd96c35561a52572ec2a66449f06bb","bugs":{"url":"https://github.com/bposman/docxtemplater/issues"},"homepage":"https://github.com/bposman/docxtemplater#readme","_id":"@bposman/docxtemplater@2.1.6","_nodeVersion":"16.20.2","_npmVersion":"8.19.4","dist":{"integrity":"sha512-OwQugUaVy9KIzmmpw3FC2VupIC6VwmJE4ThXhzK5+PLA5IDGwK9JRIPCQChuQbd+By4PO7vBd4t13QYPBtsBhg==","shasum":"1ba1fa37b70b660e60f879c6fd533b29e23c1271","tarball":"https://registry.npmjs.org/@bposman/docxtemplater/-/docxtemplater-2.1.6.tgz","fileCount":61,"unpackedSize":1949163,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICjx864kp2d0xFNS+ZGIyaRbMVUQ8IozuP7Blf0B27IhAiEA5kNW/kWeQrP2Ugy0mn+E6ens+A2ED64mKJ+iPS8yJAs="}]},"_npmUser":{"name":"bposman","email":"ben.osman@experian.com"},"directories":{},"maintainers":[{"name":"bposman","email":"ben.osman@experian.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/docxtemplater_2.1.6_1715169814503_0.9148013507944084"},"_hasShrinkwrap":false}},"time":{"created":"2024-05-08T12:03:34.395Z","2.1.6":"2024-05-08T12:03:34.805Z","modified":"2024-05-08T12:03:35.049Z"},"maintainers":[{"name":"bposman","email":"ben.osman@experian.com"}],"description":".docx generator working with templates and data (like Mustache)","homepage":"https://github.com/bposman/docxtemplater#readme","keywords":["docx","templates","generation","microsoft word"],"repository":{"type":"git","url":"git+https://github.com/bposman/docxtemplater.git"},"contributors":[{"name":"Edgar Hipp"}],"author":{"name":"Edgar Hipp"},"bugs":{"url":"https://github.com/bposman/docxtemplater/issues"},"license":"MIT","readme":"docxtemplater\n=============\n\n[![Join the chat at https://gitter.im/open-xml-templating/docxtemplater](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/open-xml-templating/docxtemplater?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)\n\n[![Build Status](https://travis-ci.org/open-xml-templating/docxtemplater.svg?branch=master&style=flat)](https://travis-ci.org/open-xml-templating/docxtemplater) [![Download count](https://img.shields.io/npm/dm/docxtemplater.svg?style=flat)](https://www.npmjs.org/package/docxtemplater) [![Current tag](https://img.shields.io/npm/v/docxtemplater.svg?style=flat)](https://www.npmjs.org/package/docxtemplater) [![Issues closed](https://issuestats.com/github/open-xml-templating/docxtemplater/badge/issue?style=flat)](https://issuestats.com/github/open-xml-templating/docxtemplater)\n\n![docxtemplater logo](https://raw.githubusercontent.com/open-xml-templating/docxtemplater/master/logo_small.png)\n\n**docxtemplater** is a library to generate docx/pptx documents from a docx/pptx template. It can replace {placeholders} with data and also supports loops and conditions. The templates can be edited by non-programmers, eg for example your clients.\n\n*Note*: The CLI will soon be moved to another repository : keep posted on https://github.com/open-xml-templating/docxtemplater-cli\n\nFeatures\n--------\n\n[Demo Site](http://javascript-ninja.fr/docxtemplater/v1/examples/demo.html)\n\n-\t<a href=\"http://javascript-ninja.fr/docxtemplater/v1/examples/demo.html#variables\">Replace a {placeholder} by a value</a>\n-\t<a href=\"http://javascript-ninja.fr/docxtemplater/v1/examples/demo.html#loops\">Use loops: {#users} {name} {/users} </a>\n-\t<a href=\"http://javascript-ninja.fr/docxtemplater/v1/examples/demo.html#tables\">Use loops in tables to generate columns</a>\n-\t<a href=\"http://javascript-ninja.fr/docxtemplater/v1/examples/demo.html#parsing\">Use expressions {product.unit_price*product.count} with angular Parsing</a>\n-\t<a href=\"http://javascript-ninja.fr/docxtemplater/v1/examples/demo.html#rawxml\">Insert custom XML {@rawXml} (for formatted text for example)</a>\n\nQuickstart in Node\n------------------\n\nInstallation: `npm install docxtemplater`\n\n```javascript\nvar fs = require('fs');\nvar Docxtemplater = require('docxtemplater');\n\n//Load the docx file as a binary\nvar content = fs\n    .readFileSync(__dirname + \"/input.docx\", \"binary\");\n\nvar doc = new Docxtemplater(content);\n\n//set the templateVariables\ndoc.setData({\n    \"first_name\":\"Hipp\",\n    \"last_name\":\"Edgar\",\n    \"phone\":\"0652455478\",\n    \"description\":\"New Website\"\n});\n\n//apply them (replace all occurences of {first_name} by Hipp, ...)\ndoc.render();\n\nvar buf = doc.getZip()\n             .generate({type:\"nodebuffer\"});\n\nfs.writeFileSync(__dirname+\"/output.docx\",buf);\n```\n\nYou can download [input.docx](https://github.com/open-xml-templating/docxtemplater/raw/master/examples/tagExample.docx) and put it in the same folder than your script.\n\nQuickstart in the browser\n-------------------------\n\n### Installation\n\n#### JS download\n\nYou can directly download built versions from github : https://github.com/open-xml-templating/docxtemplater-build/tree/master/build\n\nIf you download the JS from there, you should use `new Docxgen()` instead of `new Docxtemplater()`, because I do not want to bring in a breaking change on a minor version change in the docxtemplater-build repository.\n\n#### Bower\n\n```bash\nbower install --save docxtemplater\n```\n\nIf you download the JS from there, you should use `new Docxgen()` instead of `new Docxtemplater()`, because I do not want to bring in a breaking change on a minor version change in the docxtemplater-build repository.\n\n#### Build it yourself\n\nI recommend you to use the npm scripts I wrote (which can be found in the package.json).\n\n```bash\ngit clone git@github.com:edi9999/docxtemplater.git && cd docxtemplater\n# git checkout v2.0.0 # Optional\nnpm install\nnpm run compile\n# Optionally :\n# npm run browserify\n# npm run uglify:lib\n```\n\nDocxtemplater will be exported to window.Docxtemplater for easy usage (on some systems, it might export it in window.docxtemplater (see https://github.com/edi9999/docxtemplater/issues/118)\\)\n\nYour version of docxtemplater will be in /build (minified and non minified options) and already include all dependencies\n\n### Html demo\n\nCreate the following html\n\n```html\n<html>\n    <script src=\"build/docxtemplater.js\"></script>\n    <script src=\"vendor/FileSaver.min.js\"></script>\n    <script src=\"vendor/jszip-utils.js\"></script>\n    <!--\n    Mandatory in IE 6, 7, 8 and 9.\n    -->\n    <!--[if IE]>\n        <script type=\"text/javascript\" src=\"examples/vendor/jszip-utils-ie.js\"></script>\n    <![endif]-->\n    <script>\n    var loadFile=function(url,callback){\n        JSZipUtils.getBinaryContent(url,callback);\n    }\n    loadFile(\"examples/tagExample.docx\",function(err,content){\n        if (err) { throw e};\n        doc=new Docxtemplater(content);\n        doc.setData( {\"first_name\":\"Hipp\",\n            \"last_name\":\"Edgar\",\n            \"phone\":\"0652455478\",\n            \"description\":\"New Website\"\n            }\n        ) //set the templateVariables\n        doc.render() //apply them (replace all occurences of {first_name} by Hipp, ...)\n        out=doc.getZip().generate({type:\"blob\"}) //Output the document using Data-URI\n        saveAs(out,\"output.docx\")\n    })\n    </script>\n</html>\n```\n\nDocumentation\n-------------\n\nThe full documentation of the latest version can be found on [read the docs](http://docxtemplater.readthedocs.io/en/latest/).\n=============================================================================================================================\n\nSee [CHANGELOG.md](CHANGELOG.md) for information about how to migrate from older versions.\n\nSimilar libraries\n-----------------\n\nThey are a few similar libraries that work with docx, here’s a list of those I know a bit about:\n\n-\tdocx4j :JAVA, this is probably the biggest docx library out there. They is no built in templating engine, but you can generate your docx yourself programmatically\n-\tdocx.js: Javascript in the browser, you can create (not modify) your docx from scratch, but only do very simple things such as adding non formatted text\n-\txlsx-templater : its working quite well, does the same as here but for xlsx\n\nModules\n=======\n\nFunctionality can be added with modules. They is yet no doc for the modules because it is not completely mature yet, but you can open an issue if you have any question about it.\n\nHere is the list of existing modules:\n\n-\tChart Module using the syntax: `{$chart}` , user contributed https://github.com/prog666/docxtemplater-chart-module\n-\tImage module using the syntax: `{%image}`, https://github.com/open-xml-templating/docxtemplater-image-module\n-\tHyperlink module using the syntax: `{^link}`, https://github.com/sujith3g/docxtemplater-link-module\n\nProfessional Support\n====================\n\nI can give your company support for installing, extending, answering support questions, or maintainning your app that runs docxtemplater. You can find my email address on my [profile](https://github.com/edi9999)\n","readmeFilename":"readme.md"}