requirehtml

require() for html


License
BSD-2-Clause
Install
npm install requirehtml@0.1.0

Documentation

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