Skip to content

GregoryPotdevin/react-hogan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Licensed under the MIT license

Made with ♥ by @GregoryPotdevin at AppCraft

About

React component wrapping Hogan.js (templating engine)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages