Template.subview expects a view instance instead of a template and params hash.

This commit is contained in:
Corey Johnson & Nathan Sobo 2011-12-29 12:17:52 -06:00
parent 8455507566
commit b25fc80c9a
3 changed files with 3 additions and 4 deletions

View File

@ -16,7 +16,7 @@ describe "Template", ->
@div =>
@h1 attrs.title
@list()
@subview 'subview', subviewTemplate, title: "Subview"
@subview 'subview', subviewTemplate.build(title: "Subview")
list: ->
@ol =>

View File

@ -53,7 +53,7 @@ describe "Builder", ->
it "inserts a view built from the given template with the given params", ->
builder.tag 'div', ->
builder.tag 'h1', "Superview"
builder.subview 'sub', template, title: "Subview"
builder.subview 'sub', template.build(title: "Subview")
fragment = builder.toFragment()
expect(fragment.find("h1:contains(Superview)")).toExist()

View File

@ -41,11 +41,10 @@ class Builder
@text(options.text) if options.text
@document.push(new CloseTag(name))
subview: (outletName, template, params) ->
subview: (outletName, subview) ->
subviewId = _.uniqueId('subview')
@tag 'div', id: subviewId
@postProcessingFns.push (view) ->
subview = template.build(params)
subview.attr('outlet', outletName)
view.find("div##{subviewId}").replaceWith(subview)