Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
rivets
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
bbc1d12f
authored
2012-08-10 01:47:17 -0700
by
Michael Richards
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Skip all nodes in an iteration context unless building the views for the iterated items.
1 parent
b0cb46e2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
25 deletions
src/rivets.coffee
src/rivets.coffee
View file @
bbc1d12
...
...
@@ -114,38 +114,52 @@ class Rivets.View
# Builds the Rivets.Binding instances for the view.
build
:
=>
@
bindings
=
[]
skipNodes
=
[]
iterator
=
null
bindingRegExp
=
@
bindingRegExp
()
eventRegExp
=
/^on-/
iterationRegExp
=
/^each-/
parseNode
=
(
node
)
=>
for
attribute
in
node
.
attributes
if
bindingRegExp
.
test
attribute
.
name
options
=
{}
type
=
attribute
.
name
.
replace
bindingRegExp
,
''
pipes
=
(
pipe
.
trim
()
for
pipe
in
attribute
.
value
.
split
'|'
)
context
=
(
ctx
.
trim
()
for
ctx
in
pipes
.
shift
().
split
'>'
)
path
=
context
.
shift
()
splitPath
=
path
.
split
/\.|:/
options
.
formatters
=
pipes
model
=
@
models
[
splitPath
.
shift
()]
options
.
bypass
=
path
.
indexOf
(
":"
)
!=
-
1
keypath
=
splitPath
.
join
()
if
model
if
dependencies
=
context
.
shift
()
options
.
dependencies
=
dependencies
.
split
/\s+/
if
eventRegExp
.
test
type
type
=
type
.
replace
eventRegExp
,
''
options
.
special
=
"event"
unless
node
in
skipNodes
for
attribute
in
node
.
attributes
if
bindingRegExp
.
test
attribute
.
name
type
=
attribute
.
name
.
replace
bindingRegExp
,
''
if
iterationRegExp
.
test
type
type
=
type
.
replace
iterationRegExp
,
''
options
.
special
=
"iteration"
@
bindings
.
push
new
Rivets
.
Binding
node
,
type
,
model
,
keypath
,
options
unless
@
models
[
type
.
replace
iterationRegExp
,
''
]
skipNodes
.
push
n
for
n
in
node
.
getElementsByTagName
'*'
iterator
=
[
attribute
]
for
attribute
in
iterator
or
node
.
attributes
iterator
=
null
if
bindingRegExp
.
test
attribute
.
name
options
=
{}
type
=
attribute
.
name
.
replace
bindingRegExp
,
''
pipes
=
(
pipe
.
trim
()
for
pipe
in
attribute
.
value
.
split
'|'
)
context
=
(
ctx
.
trim
()
for
ctx
in
pipes
.
shift
().
split
'>'
)
path
=
context
.
shift
()
splitPath
=
path
.
split
/\.|:/
options
.
formatters
=
pipes
model
=
@
models
[
splitPath
.
shift
()]
options
.
bypass
=
path
.
indexOf
(
":"
)
!=
-
1
keypath
=
splitPath
.
join
()
if
model
if
dependencies
=
context
.
shift
()
options
.
dependencies
=
dependencies
.
split
/\s+/
if
eventRegExp
.
test
type
type
=
type
.
replace
eventRegExp
,
''
options
.
special
=
"event"
if
iterationRegExp
.
test
type
type
=
type
.
replace
iterationRegExp
,
''
options
.
special
=
"iteration"
@
bindings
.
push
new
Rivets
.
Binding
node
,
type
,
model
,
keypath
,
options
for
el
in
@
els
parseNode
el
...
...
Please
register
or
sign in
to post a comment