Skip to content

Commit

Permalink
support for compilation options
Browse files Browse the repository at this point in the history
  • Loading branch information
emaphp committed Aug 1, 2016
1 parent 304e9bf commit 81c8c38
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/macroParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ MacroContext.prototype.resolveMacros = function(content, macros) {
var self = this;

// Replace macro expressions
content = content.code || content;
content = content.replace(regex, function(match) {
if (!self.data[match]) {
return match;
Expand Down
12 changes: 12 additions & 0 deletions test/loaderTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,16 @@ describe('loader', function() {
done();
});
});

it('should support compilation options', function(done) {
// srcName makes the loader return a {code, map} object literal
testTemplate(loader, 'compilation-options.html', {
query: {
srcName: 'foo.js'
}
}, function(output) {
assert.equal(removeFirstline(output), loadOutput('compilation-options.txt').trimRight());
done();
});
});
});
1 change: 1 addition & 0 deletions test/templates/compilation-options.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>{name}@repeat('test')</h1>
3 changes: 3 additions & 0 deletions test/templates/output/compilation-options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (Handlebars['default'] || Handlebars).template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
return "<h1>{name}" + 'test' + "</h1>\n";
},"useData":true});

0 comments on commit 81c8c38

Please sign in to comment.