gulp-templatecache

0.1.0 • Public • Published

gulp-templatecache

Gulp plugin to join AngularJS templates in one JavaScript template cache

Similar plugin: gulp-angular-templatecache

Information

Install

Install with npm

npm install --save-dev gulp-templatecache

Usage

var templateCache = require('gulp-templatecache')
 
gulp.task('scripts', function() {
  var options = {
    output: 'public/templates.js',
    stripFromPath: 'public/templates',
    prependToPath: 'partials',
    // angular module name
    moduleName: 'templates',
    minify: {}
  }
 
  gulp.src('public/templates/**/*.html')
    .pipe(templateCache(options))
    .pipe(gulp.dest('./'))
    
  // the result is a file with all templates inside
  // registered on module "templates" with the
  // path being transformed into "partials/**/*.html"
  // and saved to "public/templates.js"
})

Overview

This plugin converts a group of templates to JavaScript (html escaped as JS) and put them inside a module.run() block to inject them right into $templateCache

API

templateCache(options)

Options

output

Type: String

The output filename

moduleName

Type: String

The AngularJS module name to use. If the module does not exists yet, it will create one.

stripFromPath

Type: String Default: ``

Path fragment to remove from template path (from beginning of all template paths)

prependToPath

Type: String Default: ``

Path fragment to insert at beginning of all template path

minify

Type: Object|Boolean Default: false

Configs to pass on html-minifier. If ommitted or false, the HTML is kept untouched

Based on:

gulp-extend

karma-ng-html2js-preprocessor

LICENSE

MIT License

Readme

Keywords

Package Sidebar

Install

npm i gulp-templatecache

Weekly Downloads

10

Version

0.1.0

License

MIT

Last publish

Collaborators

  • darlanalves