Skip to content
This repository was archived by the owner on Apr 4, 2019. It is now read-only.

Commit 1e5c0fd

Browse files
committed
Merge pull request #296 from rwjblue/add-revision-to-template
Add revision to template output.
2 parents 0b46a9f + 0b2d10a commit 1e5c0fd

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

Brocfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ for (var packageName in packages.dependencies) {
174174
}
175175

176176
trees = replace(mergeTrees(trees, {overwrite: true}), {
177-
files: [ 'es6/htmlbars.js', 'amd/htmlbars.js', 'cjs/htmlbars.js' ],
177+
files: [ 'es6/htmlbars.js', 'es6/htmlbars-compiler/template-compiler.js', 'amd/htmlbars.js', 'cjs/htmlbars.js' ],
178178
patterns: [
179179
{ match: /VERSION_STRING_PLACEHOLDER/g, replacement: getVersion() }
180180
]

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"chalk": "~0.4.0",
3939
"ember-cli": "^0.1.13",
4040
"ember-cli-sauce": "0.0.7",
41-
"git-repo-version": "0.0.2",
41+
"git-repo-version": "^0.1.2",
4242
"handlebars": "mmun/handlebars.js#new-ast-3238645f",
4343
"morph-range": "^0.1.2",
4444
"qunit": "^0.7.2",

packages/htmlbars-compiler/lib/template-compiler.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { repeat } from "../htmlbars-util/quoting";
88

99
function TemplateCompiler(options) {
1010
this.options = options || {};
11+
this.revision = this.options.revision || "HTMLBars@VERSION_STRING_PLACEHOLDER";
1112
this.fragmentOpcodeCompiler = new FragmentOpcodeCompiler();
1213
this.fragmentCompiler = new FragmentJavaScriptCompiler();
1314
this.hydrationOpcodeCompiler = new HydrationOpcodeCompiler();
@@ -93,6 +94,7 @@ TemplateCompiler.prototype.endProgram = function(program, programDepth) {
9394
this.getChildTemplateVars(indent + ' ') +
9495
indent+' return {\n' +
9596
indent+' isHTMLBars: true,\n' +
97+
indent+' revision: "' + this.revision + '",\n' +
9698
indent+' blockParams: ' + blockParams.length + ',\n' +
9799
indent+' cachedFragment: null,\n' +
98100
indent+' hasRendered: false,\n' +

packages/htmlbars-compiler/tests/template-compiler-test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,12 @@ test("it omits unnecessary namespace changes", function () {
5858
equal(countNamespaceChanges('<div><svg><title><h1>foobar</h1></title></svg></div><svg></svg>'), 3);
5959
});
6060

61+
test('it adds the provided revision to the template', function () {
62+
var ast = preprocess('{{foo}}');
63+
var compiler = new TemplateCompiler({
64+
revision: 'FOO.BAR'
65+
});
66+
var program = compiler.compile(ast);
67+
68+
ok(program.indexOf('revision: "FOO.BAR"') > -1);
69+
});

0 commit comments

Comments
 (0)