Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

html-requirer

supercrabtree4MIT0.0.7

require html files to use as sub templates

require, html, string

readme

html-requirer Build Status

Allows you to require html into your js as a string for use in templates. Uses readFileSync under the hood, so works best in situations performance is not so important. i.e. build scripts.

Install

npm install html-requirer

Usage

const requireHtml = require('html-requirer');
const header = requireHtml('../../templates/header.html');

const html = `
  <!doctype html>
  <html lang="en">
  <head>
    <meta charset="utf-8">
  </head>
  <body>
    ${header}
    <section>
      <p>other stuff</p>
    </section>
  </body>
  </html>
`;