Skip to content

Browserify transform to merge files and require the merged fille

License

Notifications You must be signed in to change notification settings

Tanoemon/haribotify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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/
})

About

Browserify transform to merge files and require the merged fille

Resources

License

Stars

Watchers

Forks

Packages

No packages published