8000 GitHub - posthtml/posthtml-include at v1.1.0
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

posthtml/posthtml-include

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PostHTML-include

npm version

Usage

index.html

<html>
<head>
    <title>index.html</title>
</head>
<body>
    <include src="component/button/button.html"></include>
</body>
</html>

component/button/button.html

<button class="button"><div class="button__text">Button</div></button>
var posthtml = require('posthtml'),
    html = require('fs').readFileSync('index.html').toString();

posthtml()
    .use(require('posthtml-include')({ encoding: 'utf-8' }))
    .process(html)
    .then(function(result) {
        console.log(result.html);
        //<html>
        //<head>
        //    <title>index.html</title>
        //</head>
        //<body>
        //    <button class="button"><div class="button__text">Text</div></button>
        //</body>
        //</html>
    })

Options

root: Root folder path for include. Default ./

encoding: Default utf-8

addDependencyTo: An object with addDependency() method, taking file path as an argument. Called whenever a file is included. Default null. You can use it for hot-reloading in webpack posthtml-loader like this:

posthtml: function(webpack) {
  return [
    require('posthtml-include')({ addDependencyTo: webpack })
  ]
}

About

Include HTML Plugin

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Contributors 20

0