grunt-angular-templates
Advanced tools
Comparing version 0.3.6 to 0.3.7
@@ -94,3 +94,11 @@ /* | ||
dest: 'tmp/concat_multiple_fixture.js' | ||
} | ||
}, | ||
noConflict: { | ||
options: { | ||
base: 'test/fixtures', | ||
noConflict: 'notGlobalAngular' | ||
}, | ||
src: 'test/fixtures/simple.html', | ||
dest: 'tmp/options_noConflict_fixture.js' | ||
}, | ||
} | ||
@@ -97,0 +105,0 @@ }); |
{ | ||
"name": "grunt-angular-templates", | ||
"description": "Grunt build task to concatenate & register your AngularJS templates in the $templateCache", | ||
"version": "0.3.6", | ||
"version": "0.3.7", | ||
"homepage": "https://github.com/ericclemmons/grunt-angular-templates", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -34,13 +34,14 @@ # grunt-angular-templates [![Build Status](https://travis-ci.org/ericclemmons/grunt-angular-templates.png?branch=master)](https://travis-ci.org/ericclemmons/grunt-angular-templates) | ||
grunt.initConfig({ | ||
ngtemplates: { | ||
myapp: { | ||
options: { | ||
base: 'src/views', // $templateCache ID will be relative to this folder | ||
prepend: '/static/assets/', // (Optional) Prepend path to $templateCache ID | ||
module: 'App' // (Optional) The module the templates will be added to | ||
// Defaults to target name (e.g. `build`) | ||
concat: 'dist/js/app.js' // (Optional) Append to existing `concat` target | ||
ngtemplates: { | ||
myapp: { | ||
options: { | ||
base: 'src/views', // $templateCache ID will be relative to this folder | ||
prepend: '/static/assets/', // (Optional) Prepend path to $templateCache ID | ||
module: 'App' // (Optional) The module the templates will be added to | ||
// Defaults to target name (e.g. `build`) | ||
concat: 'dist/js/app.js' // (Optional) Append to existing `concat` target | ||
noConflict: 'otherAngular' // (Optional) Name of angular.noConflict() app uses | ||
}, | ||
src: 'src/views/**.html', | ||
dest: 'dist/templates.js' | ||
src: 'src/views/**.html', | ||
dest: 'dist/templates.js' | ||
} | ||
@@ -138,2 +139,6 @@ } | ||
### v0.3.7 | ||
- Add `noConflict` option to work with [angular.noConflict](https://github.com/angular/angular.js/pull/1535), thanks to @mbrevoort ([#26](https://github.com/ericclemmons/grunt-angular-templates/pull/26)) | ||
### v0.3.6 | ||
@@ -140,0 +145,0 @@ |
@@ -19,9 +19,10 @@ /* | ||
grunt.registerMultiTask('ngtemplates', 'Compile AngularJS templates', function() { | ||
var id = this.options().module || this.target; | ||
var files = grunt.file.expand(this.files[0].src); | ||
var dest = path.normalize(this.files[0].dest); | ||
var done = this.async(); | ||
var options = this.options(); | ||
var id = this.options().module || this.target; | ||
var noConflict = this.options().noConflict || 'angular'; | ||
var files = grunt.file.expand(this.files[0].src); | ||
var dest = path.normalize(this.files[0].dest); | ||
var done = this.async(); | ||
var options = this.options(); | ||
compiler.compile(id, options, files, function(err, compiled) { | ||
compiler.compile(id, noConflict, options, files, function(err, compiled) { | ||
if (err) { | ||
@@ -28,0 +29,0 @@ done(false); |
@@ -26,7 +26,7 @@ /* | ||
var compile = function(id, options, files, callback) { | ||
var template = 'angular.module("<%= id %>").run(["$templateCache", function($templateCache) {\n<%= content %>\n}]);\n'; | ||
var compile = function(id, noConflict, options, files, callback) { | ||
var template = '<%= noConflict %>.module("<%= id %>").run(["$templateCache", function($templateCache) {\n<%= content %>\n}]);\n'; | ||
concat(options, files, function(err, concated) { | ||
var compiled = process(template, id, concated.join('')); | ||
var compiled = process(template, id, concated.join(''), noConflict); | ||
@@ -37,7 +37,8 @@ callback(false, compiled); | ||
var process = function(template, id, content) { | ||
var process = function(template, id, content, noConflict) { | ||
return grunt.template.process(template, { | ||
data: { | ||
id: id, | ||
content: content | ||
id: id, | ||
content: content, | ||
noConflict: noConflict | ||
} | ||
@@ -44,0 +45,0 @@ }); |
@@ -48,2 +48,12 @@ 'use strict'; | ||
noConflict: function(test) { | ||
test.expect(1); | ||
var actual = grunt.file.read('tmp/options_noConflict_fixture.js'); | ||
var expected = grunt.file.read('test/expected/options_noConflict.js'); | ||
test.equal(expected, actual, 'should reference angular by the noConflict options value'); | ||
test.done(); | ||
}, | ||
concatSimple: function(test) { | ||
@@ -50,0 +60,0 @@ test.expect(1); |
18495
18
299
217