gulp-domly

DOMly plugin for gulp

gulp-domly

DOMly plugin for gulp 3

First, install gulp-domly as a development dependency:

npm install --save-dev gulp-domly

Then, add it to your gulpfile.js:

var domly = require('gulp-domly');
 
gulp.task('templates', function(){
  gulp.src(['client/templates/*.html'])
    .pipe(domly({
      outputType: 'node'
    }))
    .pipe(gulp.dest('build/templates/'));
});

gulp-declare can be used to compile templates for the browser. Just pipe the output of gulp-domly to gulp-declare:

var domly = require('gulp-domly');
var declare = require('gulp-declare');
 
gulp.task('templates', function(){
  gulp.src(['client/templates/*.html'])
    .pipe(domly())
    .pipe(declare({
      namespace: 'MyApp.templates'
    }))
    .pipe(concat('templates.js'))
    .pipe(gulp.dest('build/js/'));
});

Type: String
Default: bare

The desired output type. One of the following:

  • node - Produce Node modules
  • amd - Produce AMD modules
  • commonjs - Produce CommonJS modules
  • bare - Return an unmolested function definition

Type: Object

Compiler options to pass to domly.precompile().