1 | # gulp-ng-templates
|
2 |
|
3 | [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=X7BZW864PRHSU)
|
4 |
|
5 | Build all of your angular templates in just one js file using `$templateCache` provider
|
6 |
|
7 | ## Installation
|
8 | ```
|
9 | npm install --save-dev gulp-ng-templates
|
10 | ```
|
11 | ```
|
12 | yarn add -D gulp-ng-templates
|
13 | ```
|
14 |
|
15 | ## Example 1
|
16 |
|
17 | ```js
|
18 | var gulp = require('gulp');
|
19 | var ngTemplates = require('gulp-ng-templates');
|
20 |
|
21 | gulp.task('templates', ['clean'], function () {
|
22 | return gulp.src(paths.templates)
|
23 | .pipe(htmlmin({collapseWhitespace: true}))
|
24 | .pipe(ngTemplates({
|
25 | filename: 'templates.js',
|
26 | module: 'App/templates',
|
27 | path: function (path, base) {
|
28 | return path.replace(base, '').replace('/templates', '');
|
29 | }
|
30 | }))
|
31 | .pipe(gulp.dest('public/js'));
|
32 | });
|
33 | ```
|
34 |
|
35 | ## Example 2
|
36 |
|
37 | ```js
|
38 | var gulp = require('gulp');
|
39 | var ngTemplates = require('gulp-ng-templates');
|
40 |
|
41 | gulp.task('templates', ['clean'], function () {
|
42 | return gulp.src(paths.templates)
|
43 | .pipe(ngTemplates('moduleName'))
|
44 | .pipe(gulp.dest('public/js'));
|
45 | });
|
46 | ```
|
47 |
|
48 | ## API
|
49 |
|
50 | gulp-ng-templates ([options](#options))
|
51 |
|
52 | ----
|
53 |
|
54 | ### options
|
55 |
|
56 | #### `path` - {function} [path=file.path, file.base]
|
57 |
|
58 | > Change the path of your templates. (See the example above)
|
59 |
|
60 | > If you not set this option it will automatically replace all of the file base path with nothing.
|
61 |
|
62 | #### `standalone` - {boolean} (default: true)
|
63 |
|
64 | > Create a new AngularJS module, instead of using an existing one.
|
65 |
|
66 | #### `htmlMinifier` - {object|boolean}
|
67 |
|
68 | > Options to pass to the [html-minifier](https://github.com/kangax/html-minifier) module
|
69 |
|
70 | ##### Defaults
|
71 | ```js
|
72 | {
|
73 | removeComments: true,
|
74 | collapseWhitespace: true,
|
75 | preserveLineBreaks: false,
|
76 | conservativeCollapse: false,
|
77 | collapseBooleanAttributes: true,
|
78 | collapseInlineTagWhitespace: true
|
79 | }
|
80 | ```
|
81 |
|
82 | #### `module` - {string} (default: templates)
|
83 |
|
84 | > Provides the module name.
|
85 |
|
86 | #### `header` - {string}
|
87 |
|
88 | > The template header, the default value is:
|
89 |
|
90 | ```js
|
91 | angular.module("<%= module %>"<%= standalone %>).run(["$templateCache", function($templateCache) {
|
92 | ```
|
93 |
|
94 | #### `footer` - {string}
|
95 |
|
96 | > The template footer, the default value is:
|
97 |
|
98 | ```js
|
99 | }]);
|
100 | ``` |
\ | No newline at end of file |