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
655ee9dc
authored
2013-06-04 17:56:14 -0700
by
Michael Richards
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Add if and unless binders for binding and unbding entire subviews in a template. [Closes #173]
1 parent
a85a0881
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
src/rivets.coffee
src/rivets.coffee
View file @
655ee9d
...
...
@@ -361,6 +361,53 @@ Rivets.binders =
else
el
.
textContent
=
if
value
?
then
value
else
''
if
:
block
:
true
bind
:
(
el
)
->
unless
@
marker
?
attr
=
[
'data'
,
@
view
.
config
.
prefix
,
@
type
].
join
(
'-'
).
replace
'--'
,
'-'
declaration
=
el
.
getAttribute
attr
@
marker
=
document
.
createComment
" rivets:
#{
@
type
}
#{
declaration
}
"
el
.
removeAttribute
attr
el
.
parentNode
.
insertBefore
@
marker
,
el
el
.
parentNode
.
removeChild
el
unbind
:
->
@
nested
?
.
unbind
()
routine
:
(
el
,
value
)
->
if
value
is
not
@
nested
?
if
value
models
=
{}
models
[
key
]
=
model
for
key
,
model
of
@
view
.
models
options
=
binders
:
@
view
.
options
.
binders
formatters
:
@
view
.
options
.
formatters
config
:
@
view
.
options
.
config
(
@
nested
=
new
Rivets
.
View
(
el
,
models
,
options
)).
bind
()
@
marker
.
parentNode
.
insertBefore
el
,
@
marker
.
nextSibling
else
el
.
parentNode
.
removeChild
el
@
nested
.
unbind
()
delete
@
nested
unless
:
block
:
true
bind
:
(
el
)
->
rivets
.
binders
.
if
.
bind
.
call
@
,
el
unbind
:
->
rivets
.
binders
.
if
.
unbind
.
call
@
routine
:
(
el
,
value
)
->
rivets
.
binders
.
if
.
routine
.
call
@
,
el
,
not
value
"on-*"
:
function
:
true
...
...
Please
register
or
sign in
to post a comment