attr-scope
invoke constructors at attributes to provide controller scopes for attractor
example
var observe = ;var attractor = ;var scope = Robot: Robot ;{thiscounter = ;}Robotprototype {this;};var attr =;attr;
then write some html:
BEEPY []voteBOOPS []vote
methods
var xscope =
This module is meant to be used with attractor, but you can use the module directly too.
var handle = xscope(cb)
Create a new handle(elem, rootkey)
that you can call to perform lookups.
When a value is found, cb(value, rootkey)
fires with the resolved value
.
handle.call({ _selectors: {}, scope: {} }, elem, rootkey)
Call the handle
in the context of a scope
property to use for variable
lookups. The attribute name keys of the _selectors
object will be looked up in
the html element elem
and the lookup strings will be rewritten to use a
generated _scope
parameter to hold the instantiated references in scope
at
rootkey
.
If the value at rootkey
is a function, it will be instantiated with
new node(elem, this)
for the supplied element elem
and the context this
.
install
With npm do:
npm install attr-scope
license
MIT