4.2.0 • Published 5 years ago

@phtml/include v4.2.0

Weekly downloads
-
License
CC0-1.0
Repository
github
Last release
5 years ago

pHTML Include

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:

NodeCLIEleventyGulpGrunt

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' });
4.2.0

5 years ago

4.1.0

5 years ago

4.0.0

5 years ago

3.0.0

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago