@phtml/include

4.2.0 • Public • Published

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

Package Sidebar

Install

npm i @phtml/include

Weekly Downloads

2

Version

4.2.0

License

CC0-1.0

Unpacked Size

44.1 kB

Total Files

8

Last publish

Collaborators

  • jonathantneal