node package manager

can-view-scope

Observable scopes

can-view-scope

Build Status

Observable scopes.

API

can-view-scope function

Create a lookup node for [can-mustache.key keys].

new Scope(context, [parent])

  1. context {*}: A value that represents the current context. This is often an object or observable and is the first place a key is looked up.

  2. parent {Scope}: The parent scope. If a key value is not found in the current scope, it will then look in the parent scope.

  • returns {Scope}: Returns a scope instance.

scope.add(context)

Add an object (which could be another Scope, a Map, or a plain object) to the scope.

var scope = new Scope({ foo: "bar" }).add({ baz: "qux" });
 
scope.attr("baz"); // -> "qux" 
  1. context {*}: The context of the new scope object.
  • returns {Scope}: A scope object.

scope.attr(key)

  1. key {can-mustache.key}: A dot seperated path. Use "." if you have a property name that includes a dot.
  • returns {*}: The found value or undefined if no value is found.

scope.compute(key, [options])

  1. key {can-mustache.key}: A dot seperated path. Use "." if you have a property name that includes a dot.

  2. options {can-view-scope.readOptions}: Options that configure how the key gets read.

  • returns {can-compute.computed}: A compute that can get or set key.

scope.computeData(key)

  1. key {can-mustache.key}: A dot seperated path. Use "." if you have a property name that includes a dot.

  2. options {can-view-scope.readOptions}: Options that configure how the key gets read.

  • returns {Object}: An object with the following values:

Contributing

Making a Build

To make a build of the distributables into dist/ in the cloned repository run

npm install
node build

Running the tests

Tests can run in the browser by opening a webserver and visiting the test.html page. Automated tests that run the tests from the command line in Firefox can be run with

npm test