Skip to content

Concatenates and registers AngularJS templates in the $templateCache.

License

Notifications You must be signed in to change notification settings

VentureCraft/gulp-viewcache

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gulp-viewcache

License NPM version NPM version Build Status Dependency Status

Concatenates and registers view templates in the $templateCache.

Install | Example | API | Releases | License


Install

Install with npm

npm install gulp-viewcache --save-dev

Example

gulpfile.js

Concatinate the contents of all .html-files in the templates directory and save to public/templates.js (default filename).

var templateCache = require('gulp-viewcache');

gulp.task('default', function () {
	gulp.src('templates/**/*.html')
		.pipe(templateCache())
		.pipe(gulp.dest('public'));
});

Result (public/templates.js)

Sample output (prettified).

define(function (require) {
    var $templateCache = {};
    $templateCache["template1.html",
        // template1.html content (escaped)
    ];
    $templateCache["template2.html",
        // template2.html content (escaped)
    ];
    // etc.
 });

Require the generated template file in your file, and use the load method to call the template of choice.

API

NB This API is from the oroginal package, and is out of date...

gulp-viewcache(filename, options)


filename - {string} [filename='templates.js']

Name to use when concatinating.

options

root - {string} [root='']

Prefix for template URLs.

module - {string} [module='templates']

Name of AngularJS module.

standalone - {boolean} [standalone=false]

Create a new AngularJS module, instead of using an existing.

base {string | function} [base=file.base]

Override file base path.

moduleSystem {string} [moduleSystem]

Wrap the templateCache in a module system. Currently supported systems: RequireJS, Browserify.

License

The MIT License (MIT)

Copyright (c) 2014 Mickel

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Concatenates and registers AngularJS templates in the $templateCache.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%