gulp-template-extend

1.0.2 • Public • Published

gulp-template-extend

Build Status GitHub license

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>

Package Sidebar

Install

npm i gulp-template-extend

Weekly Downloads

2

Version

1.0.2

License

MIT

Unpacked Size

36.6 kB

Total Files

24

Last publish

Collaborators

  • yusrilhs