Skip to content
/ include Public
forked from reshape/include

plugin that adds the ability to include html from other files

License

Notifications You must be signed in to change notification settings

carrot/include

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reshape Include

npm tests dependencies coverage

Include other HTML files ("partials") into your HTML.

Install

npm i reshape-include --save

Usage

Given the following input files:

<!-- index.html -->
<p>Here's my partial:</p>
<include src='_partial.html'></include>
<p>after the partial</p>
<!-- _partial.html -->
<strong>hello from the partial!</strong>

Process them with reshape:

const {readFileSync} = require('fs')
const reshape = require('reshape')
const include = require('reshape-include')

const html = readFileSync('index.html')

reshape({ plugins: include() })
  .process(html)
  .then((result) => console.log(result.output()))

Output:

<p>Here's my partial:</p>
<strong>hello from the partial!</strong>
<p>after the partial</p>

Options

All options are optional, none are required.

Name Description Default
root Root path to resolve the include from the file's path.
addDependencyTo Object with addDependency() method, taking file path as an argument. Called whenever a file is included.

License

About

plugin that adds the ability to include html from other files

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%