0.1.0 • Published 8 years ago

requirehtml v0.1.0

Weekly downloads
4
License
BSD-2-Clause
Repository
github
Last release
8 years ago

requirehtml

Allows you to require HTML files in Node. Implements the HTML Imports algorithm.

<script>
module = { exports: {} };
</script>
<script>
(function() {
  class Foo {
    constructor() {
      console.log('You got a foo');
    }
  }

  module.exports = Foo;
})();
</script>
var requireHTML = require('requirehtml')(module);

var Foo = requireHTML("./foo.html");

new Foo(); // -> "You got a foo"

Install

npm install requirehtml --save

API

makeRequire(module)

To make a requirer function provide the module as the starting point.

var makeRequire = require("requirehtml");
var requireHTML = makeRequire(module);

License

BSD 2-Clause