marcbachmann / node-html-pdf

This repo isn't maintained anymore as phantomjs got dreprecated a long time ago. Please migrate to headless chrome/puppeteer.
MIT License
3.56k stars 543 forks source link

Is it possible to add logic to the footer contents in the config.js #475

Open MikeSav opened 6 years ago

MikeSav commented 6 years ago

This may seem a silly request / question but in my config I have set the default footer as I need to reference the page numbers, this is what I have...

footer: { height: '15mm', contents: { default: '<div class="invoice-footer">\n' + '<div class="invoice-footer__page-number">{{page}} of {{pages}}</div></div>' // fallback value } },

It would be great if I could reference the HTML template here and/or add some conditional code (using Handlebars or some mark up) something like this

footer: { height: '15mm', contents: { default: '<div class="invoice-footer">\n' + '{{#if someValueFromTheTemplate}} Hello World {{/if}}' + {{#if someValueFromTheTemplate}} {{ someValueFromTheTemplate }} {{/if}}' + '<div class="invoice-footer__page-number">{{page}} of {{pages}}</div></div>' // fallback value } },

Is something like this possible? Or can I replace the footer.contents depending on some JS logic in the config?