@frctl/adapters

0.2.1 • Public • Published

Fractal template engine adapters

Work-in-progress template engine adapters for Fractal v2.

Build Status NPM Version

Overview

This repository contains a collection of template engine adapters for Fractal that can be used to render HTML output of component view files.

The currently available adapters are:

  • React
  • Nunjucks
  • Handlebars
const fractal = require('@frctl/fractal');
const adapters = require('@frctl/adapters');

const parser = fractal({
  src: './path/to/components',
  adapters: [
    adapters.nunjucks
  ]
});

parser.parse(function(err, components) {
  if (err) {
    return console.log(err);
  }

  const component = components.find({
    name: 'button'
  });
  const view = component.files.find({
    role: 'view',
    adapter: 'nunjucks'
  }); // get the nunjucks template for the 'button' component

  components.renderView(view, {label: 'Click me!'}, function(err, html){
    console.log(html);
  });

});

Installation

The adapters in this repository are included with Fractal by default so do not need to be installed manually.

However, the underlying template engines do need to be installed in your project before the corresponding adapter can be used.

Nunjucks

npm i nunjucks --save

Handlebars

npm i handlebars --save

React

npm i react react-dom babel-register babel-preset-es2015 babel-preset-react --save

Requirements

Node >= v6.0 is required.

Readme

Keywords

Package Sidebar

Install

npm i @frctl/adapters

Weekly Downloads

10

Version

0.2.1

License

MIT

Last publish

Collaborators

  • mihkeleidast
  • chapabu
  • tomdavies
  • allmarkedup
  • dkhuntrods