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
d434dca9
authored
2013-10-18 17:49:54 -0700
by
Michael Richards
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Take both the start and end delimiter into account when tokenizing a text template. [#219]
1 parent
615d3296
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
5 deletions
src/parsers.coffee
src/parsers.coffee
View file @
d434dca
...
...
@@ -33,7 +33,6 @@ class Rivets.TextTemplateParser
@
parse
:
(
template
,
delimiters
)
->
tokens
=
[]
length
=
template
.
length
delimiterOffset
=
delimiters
[
1
].
length
index
=
0
lastIndex
=
0
...
...
@@ -47,11 +46,11 @@ class Rivets.TextTemplateParser
if
index
>
0
and
lastIndex
<
index
tokens
.
push
type
:
@
types
.
text
,
value
:
template
.
slice
lastIndex
,
index
lastIndex
=
index
+
2
lastIndex
=
index
+
delimiters
[
0
].
length
index
=
template
.
indexOf
delimiters
[
1
],
lastIndex
if
index
<
0
substring
=
template
.
slice
lastIndex
-
2
substring
=
template
.
slice
lastIndex
-
delimiters
[
1
].
length
lastToken
=
tokens
[
tokens
.
length
-
1
]
if
lastToken
?
.
type
is
@
types
.
text
...
...
@@ -61,8 +60,8 @@ class Rivets.TextTemplateParser
break
value
=
template
.
slice
(
lastIndex
,
index
)
.
trim
()
value
=
template
.
slice
(
lastIndex
,
index
)
tokens
.
push
type
:
@
types
.
binding
,
value
:
value
lastIndex
=
index
+
delimiter
Offset
lastIndex
=
index
+
delimiter
s
[
1
].
length
tokens
...
...
Please
register
or
sign in
to post a comment