@sanktionsfrei/shared-fax-template

v3.3.2

Published

šŸ“˜ Main fax template to be shared between frontend & backend and to be consumed by handlebars

Downloads

1

Readme

shared-fax-template

šŸ“˜ Main fax template to be shared between frontend & backend and to be consumed by handlebars

The idea behind this is that we can share the main template between the cronjobs and the frontend, making it easier for everyone to maintain the text content.

This includes the regular node build and one build for the browser.

Browser

Include ./dist/fax-template.js as script in your HTML page. It exports the precompiled template to Handlebars.templates.fax

<html>
  <body>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.6/handlebars.runtime.min.js"></script>
    <script src="/assets/shared-fax-template/dist/fax-template.js"></script>
    <script>
      console.log(Handlebars.templates.fax({firstName: 'Robin'}))
    </script>
  </body>
</html>

Node

In node it's exported as regular CommonJS module.

package.json

"dependencies": {
  "shared-fax-template": "sanktionsdev/shared-fax-template"
}

Your code

const Handlebars = require('handlebars')
const faxTemplate = require('shared-fax-template')

const template = Handlebars.compile(window.faxTemplate)
console.log(template({firstName: 'Robin'}))