1.0.0 • Published 8 years ago

haribotify v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

haribotify

A Browserify transform which merges HTML files and require it.

Installation

npm install --save-dev haribotify

Usage

CLI

  $ browserify script.js -o bundle.js -t [ haribotify ]

Node

var fs = require("fs");
var browserify = require("browserify");
browserify("./script.js")
  .transform("haribotify")
  .bundle()
  .pipe(fs.createWriteStream("bundle.js"));

Require html files:

var html = require('./html/base.html');

Then the base.html is automatically transformed:

./html/base.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>This is base</title>
  </head>
  <body>
    {{./components/main.html}}
  </body>
</html>

NOTE: The root path of components is where thier base html file (index.html in this case) is placed.

./html/components/main.html

<div>This is the main component</div>

to:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>This is base</title>
  </head>
  <body>
    <div>This is the main component</div>
  </body>
</html>

Options

You can change the formatting rule of components paths. Its default is /{{(.*?)}}/g

browserify().transform("haribotify", {
  format: /regex/
})