Skip to content

Commit 1a28e23

Browse files
authored
Merge pull request #160 from tandrewnichols/empty-header-footer
Allow empty header and footer
2 parents 4639a75 + 6a37b2c commit 1a28e23

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ function templateCache(filename, options) {
171171
* Prepare header / footer
172172
*/
173173

174-
var templateHeader = options.templateHeader || TEMPLATE_HEADER;
175-
var templateFooter = options.templateFooter || TEMPLATE_FOOTER;
174+
var templateHeader = 'templateHeader' in options ? options.templateHeader : TEMPLATE_HEADER;
175+
var templateFooter = 'templateFooter' in options ? options.templateFooter : TEMPLATE_FOOTER;
176176

177177
/**
178178
* Build templateCache

test/test.js

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

415+
it('should accept empty strings as header and footer', function (cb) {
416+
var stream = templateCache('templates.js', {
417+
templateHeader: '',
418+
templateFooter: ''
419+
});
420+
421+
stream.on('data', function (file) { assert
422+
assert.equal(file.path, path.normalize(__dirname + '/templates.js'));
423+
assert.equal(file.relative, 'templates.js');
424+
assert.equal(file.contents.toString('utf8'), '$templateCache.put(\'/template-a.html\',\'yoo\');');
425+
cb();
426+
});
427+
428+
stream.write(new Vinyl({
429+
base: __dirname,
430+
path: __dirname + '/template-a.html',
431+
contents: new Buffer('yoo')
432+
}));
433+
434+
stream.end();
435+
});
415436
});
416437

417438
describe('options.templateBody', function () {

0 commit comments

Comments
 (0)