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
c5f6d853
authored
2013-03-25 12:26:03 -0500
by
Adam Heath
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Abstract out the attribute value expression parser.
1 parent
cc4d7ee8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
22 deletions
src/rivets.coffee
src/rivets.coffee
View file @
c5f6d85
...
...
@@ -117,6 +117,31 @@ loopDeps = (binder, callback) ->
callback
model
,
keypath
defaultExpressionParser
=
(
view
,
node
,
type
,
models
,
value
)
->
pipes
=
(
pipe
.
trim
()
for
pipe
in
value
.
split
'|'
)
context
=
(
ctx
.
trim
()
for
ctx
in
pipes
.
shift
().
split
'<'
)
path
=
context
.
shift
()
splitPath
=
path
.
split
/\.|:/
options
=
{}
options
.
formatters
=
pipes
options
.
bypass
=
path
.
indexOf
(
':'
)
!=
-
1
options
.
bindContext
=
models
if
splitPath
[
0
]
model
=
models
[
splitPath
.
shift
()]
else
model
=
models
splitPath
.
shift
()
keypath
=
splitPath
.
join
'.'
if
model
if
dependencies
=
context
.
shift
()
options
.
dependencies
=
dependencies
.
split
/\s+/
binding
=
new
Rivets
.
Binding
node
,
type
,
model
,
keypath
,
options
binding
.
view
=
view
binding
# A collection of bindings built from a set of parent elements.
class
Rivets
.
View
# The DOM elements and the model objects for binding are passed into the
...
...
@@ -158,30 +183,10 @@ class Rivets.View
for
attribute
in
attributes
or
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
options
.
bypass
=
path
.
indexOf
(
':'
)
!=
-
1
options
.
bindContext
=
@
models
if
splitPath
[
0
]
model
=
@
models
[
splitPath
.
shift
()]
else
model
=
@
models
splitPath
.
shift
()
keypath
=
splitPath
.
join
'.'
if
model
if
dependencies
=
context
.
shift
()
options
.
dependencies
=
dependencies
.
split
/\s+/
binding
=
new
Rivets
.
Binding
node
,
type
,
model
,
keypath
,
options
binding
.
view
=
@
binding
=
defaultExpressionParser
@
,
node
,
type
,
@
models
,
attribute
.
value
if
binding
@
bindings
.
push
binding
attributes
=
null
if
attributes
...
...
Please
register
or
sign in
to post a comment