gulp-template-extend
v1.0.2
Published
Easiest way to extend or include html file using gulp.
Downloads
1
Maintainers
Readme
gulp-template-extend
Easiest way to extend or include html file using gulp.
Install
- Using npm :
npm install gulp-template-extend --save-dev
- Using yarn :
yarn add gulp-template-extend --dev
Example
my_page.html
<extend-to src="my_template.html" />
<template-section name="title">
This is page title.
</template-section>
<template-section name="content">
<h1>This is my file content.</h1>
</template-section>
my_template.html
<!DOCTYPE html>
<html lang="en">
<head>
<title><section-title /></title>
</head>
<body>
<include-file src="header.html" />
<section-content />
</body>
</html>
header.html
<header>Welcome to my page</header>
gulpfile.js
const gulp = require('gulp')
, templateExtend = require('gulp-template-extend');
gulp.task('build-page', () => {
gulp.src('my_page.html')
.pipe(templateExtend())
.pipe(gulp.dest('pages'));
});
Result will be:
<!DOCTYPE html>
<html lang="en">
<head>
<title>This is page title.</title>
</head>
<body>
<header>Welcome to my page</header>
<h1>This is my file content.</h1>
</body>
</html>