Skip to content

v0.8.2

Compare
Choose a tag to compare
@kentmw kentmw released this 24 Oct 21:23
· 237 commits to master since this release

Duplicate release of v0.8.1

  • _prepare is a hook inside Torso View's that allow you to add new fields to the context returned by the default prepare method without having to override prepare. You can update and add to the context by returning your own context or modify the context passed in to _prepare. Both options will mix the resulting context into the View's default prepare context (taking precedence, overriding the default keys of model and view if you choose to use them). It also will override any keys defined by prepareFields
    Example:
  _prepare: function(context) {
    context.foo = 'bar';
  }

or

  _prepare: function(context) {
    return {
      foo: 'bar'
    }
  }

Will result in a context:

{
 model: this.model.toJSON(),
 view: this.viewState.toJSON(),
 foo: 'bar'
}

during a render.

  • Added has and unset to Torso View's which alias to viewState.has and viewState.unset
  • prepareFields now can be written as an object (or function who returns an object) whose keys and values will get added to the prepare's context. This extends the existing behavior of defining prepareFields as an array (or a function that returns an array) whose values are {key: 'foo', value: bar}.
  prepareFields: {
    service: myServiceCell,
    count: 4
  }

Will result in a context:

{
  model: this.model.toJSON(),
  view: this.viewState.toJSON(),
  service: myServiceCell.toJSON(),
  count: 4
}

during a render