This package is to be used for importing & validating, templates & source map data from JSON files, which can be used to fork & templatise data received from any source (e.g. RSS, CSV, JSON) into structured template data that can be rendered using the @psytech/react-render-engine package.
Here's a simple demonstration of this, which templatises RSS feed into a selected template: https://r2c.psytech42.repl.co/
The process of templatising data from a source such as an RSS feed or data stored in CSV file into structured templates is achieved in a three step process:
- Install the package using
npm install @psytech/template-engine. - Import the template engine object using
const te = require('@psytech/template-engine'). - Import template data stored in a JSON file using
te.import.template(path), wherepathshould be the valid path for the JSON file containing templates. This statement will import template data into the memory, which can now be accessed using a variable. - Import source map stored in a JSON file using
te.import.sourceMap(path), wherepathshould be the valid path for the JSON file containing source maps. This statement will import source map data into the memory, which can now be accessed using a variable. - Templatisation can be achieved using
te.templatise(template.data[i], sourceMap.data[i], data), wheredatais mapped to layout elements oftemplateusingsourceMap.
