Policygen JS

Installation

npm install 'policygen'

If using Tailwind as your css framework

Add the following to tailwind.config.js:

module.exports = {
  content: [
    './public/*.html',
    ...,
    getPolicygenViewPath()
  ]
}

function getPolicygenViewPath() {
  return `./node_modules/policygen/**/*.{ts}`;
}

Usage

Because of issues making raw file templates available to both the browser and node libraries, the templates which are loaded in as js files with the string contents to avoid having to do filesystem lookups for the templates. We are using ejs to render on the server as it is stable and well documented but the ejs browser library caused nothing but pain so for the client/browser library we're using lodash templates instead.

Create your config

const config = {
  ...
}

Client Library (Browser)

import Policygen from "policygen/client";

Node Library (Browser)

import Policygen from "policygen";

Render

async function generatePrivacyPolicy() {
  const policygen = new Policygen({ config });
  policy = await policygen.privacyPolicy();
}

async function generateTermsOfService() {
  const policygen = new Policygen({ config });
  policy = await policygen.termsOfService();
}