7.1.0 • Published 6 years ago

jsx-render-engine v7.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

jsx-render-engine npm package

JSX library agnostic render engine. (react, preact, react-router etc.)

About

jsx-render-engine is a an in-place object manipulation engine to transform object content using a JSX library as template.

It is developed as part of metalsmith-react-templates.

You can easily write your own rendering strategies, but it currently supports the following out of the box:

Installation

Install the library via:

$ npm install --save jsx-render-engine

You will need to install other dependencies based on your chosen templating engine. For example:

$ npm install react react-dom prop-types // react

$ npm install preact preact-render-to-string // preact

$ npm install react-router // and everything for react.

Getting Started

import Engine from 'jsx-render-engine';

const engine = new Engine(
  files, // see "File Objects" below
  context, // see "Context Object" below
  options // see available options in /core/options.js
);

engine.render('home');
engine.render('about');

Object References

File Objects

const files = {
  home: {
    title: 'test',
    template: 'HomeTemplate.jsx',
    content: 'markdown content'
  },
  about: {
    title: 'about',
    template: 'AboutTemplate.jsx',
    content: 'markdown content'
  }
}

Context Object

const context = {
  path: (directory, file) => {},
  metadata: () => {}
}

Notes

Version jump to v7.0.0

As part of this package moving back into metalsmith-react-templates repository, the version has jumped from v0.1.2 to v7.0.0 to keep in-sync with the parent repository

License

MIT License © Gerald Yeo