react-hogan
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 templatecontext
, JS object to inject in the templateComponent
, component to use for the rendering (defaults todiv
)
Example
Demo site with interactive example : http://gregorypotdevin.github.io/react-hogan/
License
MIT