Permalink
Browse files

allows yielded template blocks to be optional

  • Loading branch information...
1 parent 14934d7 commit 0c15127a44e6d75b678defc1a4bbd9fafb994bb6 Christopher Sansone committed Apr 6, 2012
View
3 packages/ember-handlebars/lib/helpers/yield.js
@@ -11,6 +11,5 @@ Ember.Handlebars.registerHelper('yield', function(options) {
template = get(view, 'template');
- ember_assert("You called yield on " + view.toString() + " without supplying a template", !!template);
- template(this, options);
+ if (template) { template(this, options); }
});
View
16 packages/ember-handlebars/tests/helpers/yield_test.js
@@ -102,3 +102,19 @@ test("templates should yield to block, when the yield is embedded in a hierarchy
equal(view.$('div#container div.nesting div#block').length, 1, 'nesting view yields correctly even within a view hierarchy in the nesting view');
});
+test("block should not be required", function() {
+ TemplateTests.YieldingView = Ember.View.extend({
+ layout: Ember.Handlebars.compile('{{#view Ember.View tagName="div" classNames="yielding"}}{{yield}}{{/view}}')
+ });
+
+ view = Ember.View.create({
+ template: Ember.Handlebars.compile('<div id="container">{{view TemplateTests.YieldingView}}</div>')
+ });
+
+ Ember.run(function() {
+ view.appendTo('#qunit-fixture');
+ });
+
+ equal(view.$('div#container div.yielding').length, 1, 'yielding view is rendered as expected');
+});
+

0 comments on commit 0c15127

Please sign in to comment.