gulp-pug-template-concat

1.1.1 • Public • Published

gulp-pug-template-concat

Compiles Pug templates single file containing template functions. Supports commonJS.

Based on gulp-jade-templates-concat by Nicholas Stonehouse.

Install

$ npm install --save-dev gulp-pug-template-concat

Usage

Gulpfile

var pug = require('gulp-pug');
var pugConcat = require('gulp-pug-template-concat');
 
gulp.task("client-templates", function(){
    gulp.src('src/pug/templates/**/*.pug')
        .pipe(pug({
            client: true
        })
        .pipe(pugConcat('mytemplates.js', {
            // uncomment to change templateVariable name. "templates" by default
            // templateVariable: "templates"
            
            // uncomment following line to export templates in commonJS manner
            // commonJS: true        
        }))
        .pipe(gulp.dest('build/templates/'))
});

This compiles all of your client side pug templates into a file called mytemplates.js. The templateVariable option is optional and will default to templates if it is not set.

HTML/Pug

Link the concatenated file with a script tag

script(src="templates/mytemplates.js")

Javascript

Access the generated templates using dot or bracket access notation.

  templates['template1'];
  templates.template2;

Package Sidebar

Install

npm i gulp-pug-template-concat

Weekly Downloads

1

Version

1.1.1

License

MIT

Unpacked Size

17.4 kB

Total Files

13

Last publish

Collaborators

  • drfisher