• Stars
    star
    122
  • Rank 292,031 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 10 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Compile Handlebars templates to React.

handlebars-react NPM Version Build Status Dependency Status

Compile Handlebars templates to React.

Compile this:

<div>
	text1
	{{variable1}}
	{{#if variable2}}<span>text2</span>{{else}}text3{{/if}}
	<span data-attr="{{#if variable3}}value1{{/if}} value2">text4</span>
</div>

into this:

React.DOM.div(null,
	"text1",
	this.props.variable1,
	this.props.variable2 ? React.DOM.span(null,
		"text2"
	) : "text3",
	React.DOM.span({"data-attr":(this.props.variable3 ? "value1" : "") + " value2"},
		"text4"
	)
);

Installation

Node.js >= 5 is required; < 5.0 will need an ES6 compiler. Type this at the command line:

npm install handlebars-react

Usage

Server/Browserify

var HandlebarsReact = require("handlebars-react");

new HandlebarsReact(options)
.compile("<h1>{{title}}</h1>")
.then(result => console.log("done!"));

UMD/AMD/etc

Accessible via define() or window.HandlebarsReact.

Options

options.beautify

Type: Boolean
Default value: false
When true, output will be formatted for increased legibility.

options.env

Type: String
Default value: undefined
Option presets for your target environment: "development" or "production". Preset options can be overridden.

options.normalizeWhitespace

Type: Boolean
Default value: false
See handlebars-html-parser.

options.processCSS

Type: Boolean
Default value: false
See handlebars-html-parser.

options.processJS

Type: Boolean
Default value: false
See handlebars-html-parser.

options.useDomMethods

Type: Boolean
Default value: false
When true, available React.DOM convenience functions will be used instead of React.createElement().

Roadmap Features

  • convertHbsComments to JavaScript block comments (or HTML comments?)
  • convertHtmlComments to JavaScript block comments
  • ignoreComments option when React supports such (react#2810)
  • trimWhitespace option to remove spaces between elements (<tag> a word <tag> to <tag>a word<tag>)?

Changelog

  • 0.0.1–0.0.16 pre-releases

More Repositories

1

broken-link-checker

Find broken links, missing images, etc within your HTML.
JavaScript
1,785
star
2

relateurl

Create a relative URL with options to minify.
JavaScript
53
star
3

handlebars-html-parser

Parse Handlebars and HTML.
JavaScript
33
star
4

hidefile

Hide files and directories on all platforms.
JavaScript
27
star
5

winattr

Foolproof Windows® file attributes.
JavaScript
23
star
6

universal-url

WHATWG URL for Node & Browser.
JavaScript
21
star
7

cli-clear

Cross-platform terminal screen clear.
JavaScript
16
star
8

limited-request-queue

Interactively manage concurrency for outbound requests.
JavaScript
15
star
9

camelcase-css

Convert a kebab-cased CSS property into a camelCased DOM property.
JavaScript
13
star
10

normalize-html-whitespace

Safely remove repeating whitespace from HTML text.
JavaScript
12
star
11

html-minify

Reduce file size by shortening URLs and safely removing all standard comments and unnecessary white space from an HTML document.
PHP
12
star
12

jquery.wrecker

wRECkeR: Responsive Equal-Height Columns and Rows
JavaScript
10
star
13

isurl

Determines whether a value is a WHATWG URL.
JavaScript
10
star
14

handlebars-virtual-dom

Compile Handlebars templates to virtual-dom.
9
star
15

url-to-options

Convert a WHATWG URL to an http(s).request options object.
JavaScript
7
star
16

universal-url-lite

A smaller Universal WHATWG URL, for Browserify/etc.
JavaScript
6
star
17

grunt-cleanempty

Clean empty files and folders.
JavaScript
6
star
18

jquery.transitionsend

Execute a callback when ALL css transitions have ended.
JavaScript
6
star
19

http-equiv-refresh

Parse an HTML meta refresh value.
JavaScript
6
star
20

can-transition

Seamlessly integrate CSS transitions into your CanJS v2.x projects.
JavaScript
6
star
21

grunt-log-headers

Hide the running task name header in Grunt's logger.
JavaScript
5
star
22

dom-predicates

Functions for determining if an object is a DOM Node of various types (from any Realm) via duck typing.
JavaScript
4
star
23

broquire

*DEPRECATED* Require different values in a web browser.
JavaScript
4
star
24

auto-tunnel

Simple HTTP(S) proxy tunnelling agents.
JavaScript
4
star
25

scrolling-menu

A custom element for a menu that scrolls horizontally or vertically.
JavaScript
4
star
26

absolute-to-relative-urls

A function/class for use in shortening URL links.
PHP
4
star
27

nodecon

A Node.js debugging console (Mac / Windows / Linux) *BROKEN*
JavaScript
3
star
28

minurl

Reduce and normalize the components of a WHATWG URL.
JavaScript
3
star
29

sourcetally

Source code line counter (Mac / Windows / Linux / web)
JavaScript
3
star
30

robot-directives

Parse robot directives within HTML meta and/or HTTP headers.
JavaScript
3
star
31

urlobj

*DEPRECATED* Performant utilities for URL resolution and parsing.
JavaScript
3
star
32

strip-www

Remove a leading "www" subdomain from a hostname.
JavaScript
3
star
33

edit-dotenv

Edit a .env file string with preserved comments and whitespace.
JavaScript
2
star
34

hasurl

Determine whether Node.js' WHATWG URL implementation is available.
JavaScript
2
star
35

any-match

Determine if a single match exists with an array of strings/numbers/regexes.
JavaScript
2
star
36

urlcache

Normalized URL key-value cache.
JavaScript
2
star
37

unique-number

Generate a unique number.
JavaScript
2
star
38

link-types

Parse an HTML attribute value containing link types.
JavaScript
2
star
39

cloneurl

Clone a WHATWG URL instance.
JavaScript
2
star
40

walk-parse5

Recursively traverse a parse5 DOM tree.
JavaScript
2
star
41

assign-dom-doctype

Insert, replace or remove a DocumentType node within a Document.
JavaScript
2
star
42

event-attributes

Map of HTML and SVG event attributes.
JavaScript
2
star
43

handlebars-html-compiler

Compile templates parsed with handlebars-html-parser.
2
star
44

url-relation

Determine the relation between two URLs.
JavaScript
2
star
45

nopter

*DEPRECATED* Easy command-line executable utilities built on "nopt".
JavaScript
2
star
46

dotenv-prompt

Create and edit .env files via CLI prompts.
JavaScript
2
star
47

replace-dom-string

Replace one or more strings/regexes within a DOM tree.
JavaScript
1
star
48

parse-string-boolean

Parse a string representation of a boolean.
JavaScript
1
star
49

sql-match

Match a string using an SQL pattern.
JavaScript
1
star
50

less-plugin-future-compat

Less.js plugin to avoid conflicts with future CSS features.
JavaScript
1
star
51

evaluate-value

Return a value or an evaluated function (with arguments).
JavaScript
1
star
52

is-dom-detached

Determine if a Node does not exist within a DOM tree.
JavaScript
1
star
53

which-win-shell

Discern between different command-line shells on Windows *BROKEN*
JavaScript
1
star
54

is-dom-void

Determine if an object is a void HTMLElement (from any Realm).
JavaScript
1
star
55

supports-semigraphics

Determine if a terminal/stream supports text animations.
JavaScript
1
star
56

dom-max-size

Determine the maximum scalable dimensions of an HTMLElement.
JavaScript
1
star
57

is-dom-element2

Determine if an object is an HTMLElement (from any Realm).
JavaScript
1
star
58

is-urlsearchparams

Determines whether a value is a URLSearchParams instance.
JavaScript
1
star
59

is-dom-document

Determine if an object is a DOM Document (from any Realm).
JavaScript
1
star
60

incomplete-url

Custom-remove features of a WHATWG URL implementation.
JavaScript
1
star
61

gres

CLI scripts for bootstrapping a PostgreSQL database.
JavaScript
1
star
62

mount-smb

Cross-platform SMB mounting & unmounting
1
star
63

new-js-framework

No name yet
1
star
64

cypress-issues

A repository of branches for reproducing Cypress issues.
1
star
65

create-html-template-element

Create an HTML <template> with content.
JavaScript
1
star