Options

  • constructor
inherits: can.view.Scope

Create a helper lookup node for keys. Options are where mustache helpers, partials, local tags, and other non-data objects are found.

new can.view.Options(options, [parent]) 2.1

Parameters

  1. options {Object}

    An object with at least one of the following properties:

    • helpers - Mustache helpers will be found within this object.
    • partials - Mustache partials will be found within this object.
    • tags - Local tag hookups will be found within this object.

    If none of these properties are found, the object is assumed to be a helpers object.s

  2. parent {can.view.Options}Optional

    The parent options object. If a key value is not found in the current options object, it will then look in the parent scope.

Returns

{can.view.Options}

Returns a options instance.

Use

can.view.Options is rarely used directly. However, they are indirectly created in several places:

And can.view.Options are provided several places:

  • A Mustache helper options's options property.
  • An attribute callback's data's options property.
  • A tag callback's data's options property.

Options works just like can.view.Scope except it contains references to local non-data values like:

  • mustache helpers
  • partial templates
  • tag hookups

When a mustache template is rendered, these can be specified like:

var options = {
  helpers: {
    isSelected: function( helperOptions ){ ... }
  },
  partials: {
    person: can.view("person")
  },
  tags: {
    people: function(el, tagData){ ... }
  }
}
can.view("people.mustache", data, options)

If no helpers, partials or tags properties are found, options are assumed to be helpers. The following would pass a loal isSelected to "people.mustache":

can.view("people.mustache", data, {
    isSelected: function( helperOptions ){ ... }
})