Search code examples
ember.jstowerjs

EmberJS {{#with}} block not displaying


the controller looks like this

class App.ContactsController extends Tower.Controller
  index: (params) ->
    @set('person', App.HighrisePerson.create())
    @render "index"

the view looks like this

App.ContactsEditView = Ember.View.extend
  templateName: 'contacts/edit'
  resourceBinding: 'controller.person'
  init: (args...) ->
    @._super(args...)
    console.log(@.get('resource'))
    console.log('inited')

with the above block i see in the console that resource is set to an instance of my Ember.Object

but with the following viewcode

div class: "row-fluid", ->
  text "{{#with resource}}"
  text "Hello"
  text "{{/with}}"

relevant part of parent view

div class: "row-fluid contact-form", ->
  div class: "row-fluid", ->
    h1 "Want to work with us?"
    p "So...you want to be kohactivated!?!? Please take a few moments to fill out the form below and provide us with some details about your project, company or start-up."
  text "{{view App.ContactsEditView}}"

i see no rendered output for hello

if i move hello outside of the #with block i see hello,

so I assume that it isnt recognizing resource for some reason

Any help is appreciated.


Solution

  • That's right -- it's looking for resource in the current handlebars context rather than the view (which as of ember.js 0.9.8 I believe, is no longer the default context). You'll need view.resource instead.

    (Side note: conversely, to reference the handlebars context from the view, use context.whatever)