Skip to content

Commit a9a745d

Browse files
authored
Merge pull request #162 from dmellstrom/patch-1
Add 'use strict' directive to IIFE output
2 parents a5161a3 + a6aa976 commit a9a745d

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var MODULE_TEMPLATES = {
3333
},
3434

3535
iife: {
36-
header: '(function(){',
36+
header: '(function(){\'use strict\';',
3737
footer: '})();'
3838
}
3939

test/test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,27 @@ describe('gulp-angular-templatecache', function () {
386386
stream.end();
387387
});
388388

389+
it('should support IIFE-style exports', function (cb) {
390+
var stream = templateCache('templates.js', {
391+
moduleSystem: 'IIFE'
392+
});
393+
394+
stream.on('data', function (file) {
395+
assert.equal(path.normalize(file.path), path.normalize(__dirname + '/templates.js'));
396+
assert.equal(file.relative, 'templates.js');
397+
assert.equal(file.contents.toString('utf8'), '(function(){\'use strict\';angular.module(\'templates\').run([\'$templateCache\', function($templateCache) {$templateCache.put(\'/template-a.html\',\'<h1 id="template-a">I\\\'m template A!</h1>\');}]);})();');
398+
cb();
399+
});
400+
401+
stream.write(new Vinyl({
402+
base: __dirname,
403+
path: __dirname + '/template-a.html',
404+
contents: new Buffer('<h1 id="template-a">I\'m template A!</h1>')
405+
}));
406+
407+
stream.end();
408+
});
409+
389410
});
390411

391412
describe('options.templateHeader & options.templateFooter', function () {

0 commit comments

Comments
 (0)