在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):laxa1986/gulp-angular-embed-templates开源软件地址(OpenSource Url):https://github.com/laxa1986/gulp-angular-embed-templates开源编程语言(OpenSource Language):JavaScript 93.7%开源软件介绍(OpenSource Introduction):gulp-angular-embed-templates
Plugin searches for Nearest neighbours are:
Versions / Release NotesInstall
Usage (Angular 1.x)Given the following file structure src
+-hello-world
|-hello-world-directive.js
+-hello-world-template.html
angular.module('test').directive('helloWorld', function () {
return {
restrict: 'E',
// relative path to template
templateUrl: 'hello-world-template.html'
};
});
<strong>
Hello world!
</strong>
var gulp = require('gulp');
var embedTemplates = require('gulp-angular-embed-templates');
gulp.task('js:build', function () {
gulp.src('src/scripts/**/*.js')
.pipe(embedTemplates())
.pipe(gulp.dest('./dist'));
}); gulp-angular-embed-templates will generate the following file: angular.module('test').directive('helloWorld', function () {
return {
restrict: 'E',
template:'<strong>Hello world!</strong>'
};
}); Usage (Angular 2.0)Given the following file structure src
+-hello-world
|-hello-world-component.ts
+-hello-world-template.html
class Component extends Directive {
restrict: string = "E";
controller: Controller;
controllerAs: string = "vm";
templateUrl: string = "angular2-template.html";
}
// or
@View({
...
templateUrl: 'angular2-template.html'
})
<task-cmp [model]="task" (complete)="onCmpl(task)">
{{index}}
</task-cmp>
var gulp = require('gulp');
var embedTemplates = require('gulp-angular-embed-templates');
gulp.task('js:build', function () {
gulp.src('src/scripts/**/*.ts') // also can use *.js files
.pipe(embedTemplates({sourceType:'ts'}))
.pipe(gulp.dest('./dist'));
}); gulp-angular-embed-templates will generate the following file: class Component extends Directive {
restrict: string = "E";
controller: Controller;
controllerAs: string = "vm";
template:string='<task-cmp [model]="task" (complete)="onCmpl(task)">{{index}}</task-cmp>';
}
// or
@View({
...
template:'<task-cmp [model]="task" (complete)="onCmpl(task)">{{index}}</task-cmp>'
}) Note: call embedTemplates before source maps initialization. APIembedTemplates(options)options.sourceTypeType:
options.basePathType: skip one template embeddingThe easiest way to skip one concrete is just add some comment like options.skipFilesType: options.skipTemplatesType: options.minimizeType: settings to pass in minimize plugin. Please see all settings on minimize official page. Please don't specify key 'parser' because it already used for internal purposes options.skipErrorsType: should plugin brake on errors (file not found, error in minification) or skip errors (warn in logs) and go to next template options.jsEncodingType: js files encoding (angular directives) options.templateEncodingType: angular template files encoding options.maxSizeType: define the max size limit in bytes for the template be embedded. Ignore templates which size exceed this limit LicenseThis module is released under the MIT license. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论