react-hogan

0.1.1 • Public • Published

react-hogan

Travis npm package Coveralls

React component wrapping Hogan.js. Can be used to render client-provided templates.

Why ??

It may seem weird and redundant to want to use a templating engine with React. I currently use it for 2 different use cases :

  • Simple string templating that an end user can edit, like Hello {{name}}
  • To provide external templating capabilities when exposing React components with a pure-JS API (simple JS wrapper)

Installation

npm install react-hogan --save

Features

  • Render hogan template as a React component
  • Lazy template compilation + re-rendering
  • All props besides template and context are passed directly to the

Usage

import Hogan from 'react-hogan'
<Hogan template="Hello {{name}}" context={{name: 'Gregory'}} />

Props

  • template, Mustache-compatible template
  • context, JS object to inject in the template
  • Component, component to use for the rendering (defaults to div)

Example

Demo site with interactive example : http://gregorypotdevin.github.io/react-hogan/

License

MIT

Package Sidebar

Install

npm i react-hogan

Weekly Downloads

5

Version

0.1.1

License

MIT

Last publish

Collaborators

  • gpotdevin