React component wrapping Hogan.js. Can be used to render client-provided templates.
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)
npm install react-hogan --save
- Render hogan template as a React component
- Lazy template compilation + re-rendering
- All props besides template and context are passed directly to the
import Hogan from 'react-hogan'
<Hogan template="Hello {{name}}" context={{name: 'Gregory'}} />
template
, Mustache-compatible templatecontext
, JS object to inject in the templateComponent
, component to use for the rendering (defaults todiv
)
Demo site with interactive example : http://gregorypotdevin.github.io/react-hogan/
Licensed under the MIT license
Made with ♥ by @GregoryPotdevin at AppCraft