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
467630fe
authored
2013-07-28 20:51:27 -0700
by
Michael Richards
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Implement a basic keypath parser that tokenizes a keypath into path + interface pairs.
1 parent
87343c1e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
src/rivets.coffee
src/rivets.coffee
View file @
467630f
...
...
@@ -348,6 +348,26 @@ class Rivets.View
@
models
[
key
]
=
model
for
key
,
model
of
models
binding
.
update
models
for
binding
in
@
bindings
# Rivets.KeypathParser
# --------------------
# Parser and tokenizer for keypaths in binding declarations.
class
Rivets
.
KeypathParser
# Parses the keypath and returns a set of adapter interface + path tokens.
@
parse
:
(
keypath
,
interfaces
,
root
)
->
tokens
=
[]
current
=
{
interface
:
root
,
path
:
''
}
for
index
,
char
of
keypath
if
char
in
interfaces
tokens
.
push
current
current
=
{
interface
:
char
,
path
:
''
}
else
current
.
path
+=
char
tokens
.
push
current
tokens
# Rivets.TextTemplateParser
# -------------------------
...
...
Please
register
or
sign in
to post a comment