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
ec20607f
authored
2013-10-18 01:11:17 -0700
by
Michael Richards
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge pull request #218 from mikeric/fix-template-parser-and-builder
Fix template parser and builder
2 parents
d29df654
1ae4a3fe
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
12 deletions
src/parsers.coffee
src/view.coffee
src/parsers.coffee
View file @
ec20607
...
...
@@ -33,6 +33,7 @@ class Rivets.TextTemplateParser
@
parse
:
(
template
,
delimiters
)
->
tokens
=
[]
length
=
template
.
length
delimiterOffset
=
delimiters
[
1
].
length
index
=
0
lastIndex
=
0
...
...
@@ -62,6 +63,6 @@ class Rivets.TextTemplateParser
value
=
template
.
slice
(
lastIndex
,
index
).
trim
()
tokens
.
push
type
:
@
types
.
binding
,
value
:
value
lastIndex
=
index
+
2
lastIndex
=
index
+
delimiterOffset
tokens
...
...
src/view.coffee
View file @
ec20607
...
...
@@ -54,20 +54,13 @@ class Rivets.View
if
delimiters
=
@
config
.
templateDelimiters
if
(
tokens
=
parser
.
parse
(
node
.
data
,
delimiters
)).
length
unless
tokens
.
length
is
1
and
tokens
[
0
].
type
is
parser
.
types
.
text
[
startToken
,
restTokens
...]
=
tokens
node
.
data
=
startToken
.
value
if
startToken
.
type
is
0
node
.
data
=
startToken
.
value
else
buildBinding
'TextBinding'
,
node
,
null
,
startToken
.
value
for
token
in
restTokens
for
token
in
tokens
text
=
document
.
createTextNode
token
.
value
node
.
parentNode
.
appendChild
text
node
.
parentNode
.
insertBefore
text
,
node
if
token
.
type
is
1
buildBinding
'TextBinding'
,
text
,
null
,
token
.
value
node
.
parentNode
.
removeChild
node
else
if
componentRegExp
.
test
node
.
tagName
type
=
node
.
tagName
.
replace
(
componentRegExp
,
''
).
toLowerCase
()
@
bindings
.
push
new
Rivets
.
ComponentBinding
@
,
node
,
type
...
...
@@ -94,7 +87,7 @@ class Rivets.View
type
=
attribute
.
name
.
replace
bindingRegExp
,
''
buildBinding
'Binding'
,
node
,
type
,
attribute
.
value
parse
childNode
for
childNode
in
node
.
childNodes
parse
childNode
for
childNode
in
(
n
for
n
in
node
.
childNodes
)
parse
el
for
el
in
@
els
...
...
Please
register
or
sign in
to post a comment