diff --git a/packages/ember-routing-htmlbars/lib/helpers/render.js b/packages/ember-routing-htmlbars/lib/helpers/render.js
index b384e58048f..111e6d4a7a3 100644
--- a/packages/ember-routing-htmlbars/lib/helpers/render.js
+++ b/packages/ember-routing-htmlbars/lib/helpers/render.js
@@ -124,8 +124,19 @@ export function renderHelper(params, hash, options, env) {
name = name.replace(/\//g, '.');
// \ legacy slash as namespace support
+ var templateName = 'template:' + name;
+ Ember.assert(
+ "You used `{{render '" + name + "'}}`, but '" + name + "' can not be " +
+ "found as either a template or a view.",
+ container._registry.has("view:" + name) || container._registry.has(templateName) || !!options.template
+ );
- view = container.lookup('view:' + name) || container.lookup('view:default');
+ var template = options.template;
+ view = container.lookup('view:' + name);
+ if (!view) {
+ view = container.lookup('view:default');
+ template = template || container.lookup(templateName);
+ }
// provide controller override
var controllerName;
@@ -174,14 +185,6 @@ export function renderHelper(params, hash, options, env) {
hash.viewName = camelize(name);
- var templateName = 'template:' + name;
- Ember.assert(
- "You used `{{render '" + name + "'}}`, but '" + name + "' can not be " +
- "found as either a template or a view.",
- container._registry.has("view:" + name) || container._registry.has(templateName) || !!options.template
- );
- var template = options.template || container.lookup(templateName);
-
if (router && !initialContext) {
router._connectActiveView(name, view);
}
diff --git a/packages/ember-routing-htmlbars/tests/helpers/render_test.js b/packages/ember-routing-htmlbars/tests/helpers/render_test.js
index a5a837240e8..55059199150 100644
--- a/packages/ember-routing-htmlbars/tests/helpers/render_test.js
+++ b/packages/ember-routing-htmlbars/tests/helpers/render_test.js
@@ -535,3 +535,23 @@ QUnit.test("throws an assertion if {{render}} is called with a literal for a mod
runAppend(view);
}, "The second argument of {{render}} must be a path, e.g. {{render \"post\" post}}.");
});
+
+QUnit.test("{{render}} helper should let view provide its own template", function() {
+ var template = "{{render 'fish'}}";
+ var controller = EmberController.extend({ container: container });
+ view = EmberView.create({
+ controller: controller.create(),
+ template: compile(template)
+ });
+
+ container._registry.register('template:fish', compile('Hello fish!'));
+ container._registry.register('template:other', compile('Hello other!'));
+
+ container._registry.register('view:fish', EmberView.extend({
+ templateName: 'other'
+ }));
+
+ runAppend(view);
+
+ equal(view.$().text(), 'Hello other!');
+});