npm.io
4.2.0 • Published 7 years ago

@phtml/include

Licence
CC0-1.0
Version
4.2.0
Deps
1
Size
43 kB
Vulns
0
Weekly
0
Stars
10

pHTML Include pHTML

NPM Version Build Status Support Chat

pHTML Include lets you embed HTML partials into HTML.

<!doctype html>
<html>
  <head>
    <title>phtml-include</title>
  </head>
  <body>
    <!-- where _body.html is <h1>Body Partial</h1> -->
    <include src="_body.html" />
  </body>
</html>

<!-- becomes -->

<!doctype html>
<html>
  <head>
    <title>phtml-include</title>
  </head>
  <body>
    <h1>Body Partial</h1>
  </body>
</html>

Usage

Transform HTML files directly from the command line:

npx phtml source.html output.html -p @phtml/include

Node

Add pHTML Include to your project:

npm install @phtml/include --save-dev

Use pHTML Include to process your HTML:

const phtmlInclude = require('@phtml/include');

phtmlInclude.process(YOUR_HTML /*, processOptions, pluginOptions */);

Or use it as a pHTML plugin:

const phtml = require('phtml');
const phtmlInclude = require('@phtml/include');

phtml([
  phtmlInclude(/* pluginOptions */)
]).process(YOUR_HTML /*, processOptions */);

pHTML Include runs in all Node environments, with special instructions for:

Node CLI Eleventy Gulp Grunt

Options

cwd

The cwd option defines and overrides the current working directory of includes.

// resolve all relative includes to /some/absolute/path
phtmlInclude({ cwd: '/some/absolute/path' });

Keywords