1.1.1 • Published 7 years ago

hyperify v1.1.1

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

hyperify

Build Status Standard - JavaScript Style Guide

Browserify transform for hyperHTML templates :zap:

Credit for the idea behind this module goes to @WebReflection for outlining a similar approach with https://github.com/WebReflection/viperHTML#handy-patterns. :+1:

Example

index.js

var hyperHTML = require('hyperhtml')
var template = require('./template.html')
var render = hyperHTML.bind(document.body)

template(render, {
  text: "Hello world!"
})

template.html

<div>
  ${data.text}
</div>

The template compiles down to effectively the following function:

function (render, data) {
  return render`<div>
    ${data.text}
  </div>`
}

Usage

Install hyperify via npm:

npm install hyperify -D

or yarn:

yarn add hyperify -D

Then add hyperify to your list of browserify transforms:

browserify -t hyperify index.js > bundle.js

Additionally you can configure hyperify via CLI as follows:

browserify -t [ hyperify -e '.hyper.html' -a render -a model ] index.js > bundle.js

Options

  • -e | --ext | --extension - Define which file extension to apply the transform to. Default: '.html'
  • -a | --args | --arguments - Define which arguments the template function should be called with. Default: ['render', 'data'] Note: the first arg should always be your render function.

License

MIT