A grunt task runner for angular-template-inline-js
npm install grunt-schepp-angular-template-inline-jstemplateUrl: 'file.html' in javascript code with template: 'file.html contents'.
~0.4.5
shell
npm install schepp-angular-template-inline-js --save-dev
npm install grunt-schepp-angular-template-inline-js --save-dev
`
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
`js
grunt.loadNpmTasks('grunt-schepp-angular-template-inline-js');
`
The "angular_template_inline_js" task
$3
In your project's Gruntfile, add a section named angular_template_inline_js to the data object passed into grunt.initConfig().
`js
grunt.initConfig({
angular_template_inline_js: {
options: {
// Task-specific options go here.
basePath: '',
key: ''
},
your_target: {
// Target-specific file lists and/or options go here.
},
},
});
`
$3
#### options.basePath
Type: String
The base path to use when searching for templates. If not specified, uses the current file's directory.
#### options.key
Type: String
Default value: templateUrl
The "key" to replace within the javascript code. In most cases, the default is fine, but you can change the key
if you only want to inline certain templates.
$3
#### Default Options
This example will replace all occurrences of templateUrl: 'filePath.html' with template: 'contents of template' within the app folder,
and write the result to the build folder.
`js
grunt.initConfig({
angular_template_inline_js: {
options: {
basePath: __dirname + '/app'
},
files: [{
cwd: 'app',
expand: true,
src: [ '/app/*/.js' ],
dest: 'build'
}],
},
});
`
#### Custom Options
This example sets a custom key, which will replace all occurrences of inlineTemplate: 'filePath.html' with template: 'contents of template.
`js
grunt.initConfig({
angular_template_inline_js: {
options: {
basePath: __dirname + '/app',
key: 'inlineTemplate'
},
files: [{
cwd: 'app',
expand: true,
src: [ '/app/*/.js' ],
dest: 'build'
}],
},
});
``