diff --git a/app/services/ember-cli.js b/app/services/ember-cli.js index 42dbaf19..4baa8ade 100644 --- a/app/services/ember-cli.js +++ b/app/services/ember-cli.js @@ -338,8 +338,10 @@ export default Ember.Service.extend({ // let templateCode = Ember.HTMLBars.precompile(code || ''); // Compiles all templates at runtime. + let moduleName = this.nameWithModule(filePath); + const mungedCode = (code || '').replace(/\\/g, "\\\\"); // Prevent backslashes from being escaped - return this.compileJs('export default Ember.HTMLBars.compile(`' + mungedCode + '`);', filePath); + return this.compileJs('export default Ember.HTMLBars.compile(`' + mungedCode + '`, { moduleName: `' + moduleName + '`});', filePath); }, compileCss(code, moduleName) { diff --git a/tests/unit/services/ember-cli-test.js b/tests/unit/services/ember-cli-test.js index 16b5c613..894489e6 100644 --- a/tests/unit/services/ember-cli-test.js +++ b/tests/unit/services/ember-cli-test.js @@ -149,3 +149,10 @@ test("buildProperties() works as expected with replacements", function (assert) assert.ok(props.content.indexOf('myHelper(params') !== -1, 'Replacements worked'); assert.ok(props.content.indexOf('helper(myHelper)') !== -1, 'Replacements worked if multiple'); }); + +test('compileHbs includes moduleName', function(assert) { + var service = this.subject(); + var result = service.compileHbs('foo', 'somePath/here.hbs'); + + assert.ok(result.indexOf('moduleName: "demo-app/somePath/here"') > -1, 'moduleName included'); +});