html-hole-loader
simple html layout loader for webpack
modified from html-hole-loader
Install
npm install html-hole-loader
Required
node > 6.0
Usage
- First, you need a layout html, like this:
Pure Web This is Header <!-- the place of the content will be inserted, you can change the placeholder in loader options--> {{__content__}} This is footer
-
Second, you have two way to use the layout
A. import layout template in html file, and add loader
<!-- file path can't include quotes -->@layout(../../htmls/layout.html)main contenttest: /\.$/loader: 'html-hole-loader'B. setting default layout in loader options, so you don't do any thing in html
main contenttest: /\.$/loader: 'html-hole-loader'include: htmlPath // the htmls you want inject to layoutoptions:layout: layoutHtmlPath // the path of default layout html -
you can also pass a parameter
@layout(../../htmls/layout.html, {title, "title"})main contentthen in your layout
<!-- the place of the param will be inserteds-->{{__title__}}This is Header{{__content__}}This is footer
Options
there is others options
placeholder
: the placeholder of inserted place of layout,default:{{__content__}}
decorator
: the layout syntax, default:layout
.