All Projects → miickel → Gulp Angular Templatecache

miickel / Gulp Angular Templatecache

Licence: mit
Concatenates and registers AngularJS templates in the $templateCache.

Programming Languages

javascript
137047 projects - #8 most used programming language

Projects that are alternatives of or similar to Gulp Angular Templatecache

gulp-tinypng-compress
TinyPNG API wrapper for compressing PNG & JPG images
Stars: ✭ 49 (-90.75%)
Mutual labels:  gulp, gulp-plugin
gulp-golang
gulp plugin for golang projects
Stars: ✭ 13 (-97.55%)
Mutual labels:  gulp, gulp-plugin
gulp-iife
A Gulp plugin for wrapping JavaScript code in IIFEs.
Stars: ✭ 39 (-92.64%)
Mutual labels:  gulp, gulp-plugin
Gulp Html Replace
Replace build blocks in HTML. Like useref but done right.
Stars: ✭ 222 (-58.11%)
Mutual labels:  gulp, gulp-plugin
Gulp Shell
A handy command line interface for gulp
Stars: ✭ 474 (-10.57%)
Mutual labels:  gulp, gulp-plugin
gulp-px2rem
This is a gulp plugin for node-px2rem.
Stars: ✭ 19 (-96.42%)
Mutual labels:  gulp, gulp-plugin
Meantorrent
meanTorrent - MEAN.JS BitTorrent Private Tracker - Full-Stack JavaScript Using MongoDB, Express, AngularJS, and Node.js, A BitTorrent Private Tracker CMS with Multilingual, and IRC announce support, CloudFlare support. Demo at:
Stars: ✭ 438 (-17.36%)
Mutual labels:  gulp, angularjs
Ng6 Starter
🆖 An AngularJS Starter repo for AngularJS + ES6 + Webpack
Stars: ✭ 1,933 (+264.72%)
Mutual labels:  gulp, angularjs
gulp-convert-encoding
Plugin for gulp to convert files from one encoding to another.
Stars: ✭ 15 (-97.17%)
Mutual labels:  gulp, gulp-plugin
gulp-yarn
Automatically install node modules using Yarn. 😻
Stars: ✭ 22 (-95.85%)
Mutual labels:  gulp, gulp-plugin
Ionic Starter Template
Reinventing the wheel, again! Sorry Ionic Team... but there are many newbies learning on Youtube!
Stars: ✭ 208 (-60.75%)
Mutual labels:  gulp, angularjs
King Admin
king-admin是一个超酷的前后端分离的基础权限管理后台,前端:angularJs+bootstrap+gulp,后端:spring-boot+mybatis-plus(分java版和kotlin版)
Stars: ✭ 397 (-25.09%)
Mutual labels:  gulp, angularjs
Angular2 Express Mongoose Gulp Node Typescript
AngularJS 2 (Updated to 4.2.0) Mean Stack application which uses Angular2, Gulp, Express, Node, MongoDB (Mongoose) with Repository Pattern Business Layer
Stars: ✭ 201 (-62.08%)
Mutual labels:  gulp, angularjs
gulp-recess
[DEPRECATED] Lint CSS and LESS with RECESS
Stars: ✭ 42 (-92.08%)
Mutual labels:  gulp, gulp-plugin
Fe
前端热门文章阅读
Stars: ✭ 174 (-67.17%)
Mutual labels:  gulp, angularjs
angular-material-boilerplate
A straightforward and well structured boilerplate based on Google's Angular Material project.
Stars: ✭ 28 (-94.72%)
Mutual labels:  angularjs, gulp
Glup
Some of the gulp tutorial -《gulp笔记》
Stars: ✭ 136 (-74.34%)
Mutual labels:  gulp, gulp-plugin
Gulp Tap
Easily tap into a gulp pipeline without creating a plugin.
Stars: ✭ 158 (-70.19%)
Mutual labels:  gulp, gulp-plugin
anyfs
Portable file system for Node
Stars: ✭ 17 (-96.79%)
Mutual labels:  gulp, gulp-plugin
gulp-markdown-to-json
Parse Markdown and YAML → compile Markdown to HTML → wrap it all up in JSON
Stars: ✭ 76 (-85.66%)
Mutual labels:  gulp, gulp-plugin

gulp-angular-templatecache

License NPM version NPM version Build Status Dependency Status

Concatenates and registers AngularJS templates in the $templateCache.

Install | Example | API | Releases | License


Install

Install with npm

npm install gulp-angular-templatecache --save-dev

Example

gulpfile.js

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

var templateCache = require('gulp-angular-templatecache');

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

Result (public/templates.js)

Sample output (prettified).

angular.module("templates").run([$templateCache,
  function($templateCache) {
    $templateCache.put("template1.html",
      // template1.html content (escaped)
    );
    $templateCache.put("template2.html",
      // template2.html content (escaped)
    );
    // etc.
  }
]);

Include this file in your app and AngularJS will use the $templateCache when available.

Note: this plugin will not create a new AngularJS module by default, but use a module called templates. If you would like to create a new module, set options.standalone to true.

Note: if you use Visual Studio on Windows, you might encounter this error message: ASPNETCOMPILER : error ASPRUNTIME: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

This is most likely due to long path names, and can be fixed by adding lodash.bind as a dev dependecy in your package.json. Anyway, if you encounter this error, please drop a note in #62, and we might merge #63.

API

gulp-angular-templatecache(filename, options)


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

Name to use when concatenating.

options

root - {string}

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}

Wrap the templateCache in a module system. Currently supported systems: RequireJS, Browserify, ES6 and IIFE (Immediately-Invoked Function Expression).

transformUrl {function}

Transform the generated URL before it's put into $templateCache.

transformUrl: function(url) {
	return url.replace(/\.tpl\.html$/, '.html')
}

templateHeader {string} [templateHeader=see below]

Override template header.

var TEMPLATE_HEADER = 'angular.module("<%= module %>"<%= standalone %>).run(["$templateCache", function($templateCache) {';

templateBody {string} [templateBody=see below]

Override template body.

var TEMPLATE_BODY = '$templateCache.put("<%= url %>","<%= contents %>");';

templateFooter {string} [templateFooter=see below]

Override template footer.

var TEMPLATE_FOOTER = '}]);';

escapeOptions - {object}

Options for jsesc module. See jsesc API

Changes

This plugin uses Semantic Versioning 2.0.0

1.1.0 and newer

See Releases

1.0.0

Cleaner code, more tests and improved documentation. Thoroughly used in development.

  • adds
    • options.standalone (breaking)
  • fixes
    • Windows support
  • changes
    • filename now optional

0.3.0

  • adds
    • options.module

0.2.0 and earlier

Only used by mad men

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.

Analytics

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected]