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
b775faa8
authored
2013-06-04 17:56:29 -0700
by
Michael Richards
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge pull request #176 from mikeric/if-unless-binders
Add if and unless binders
2 parents
a85a0881
655ee9dc
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
src/rivets.coffee
src/rivets.coffee
View file @
b775faa
...
...
@@ -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