ee80701f by Michael Richards

Allow template delimiters as a second option to the TextTemplateParser.parse function. [#181]

1 parent 51c50695
...@@ -292,14 +292,14 @@ class Rivets.TextTemplateParser ...@@ -292,14 +292,14 @@ class Rivets.TextTemplateParser
292 292
293 # Parses the template and returns a set of tokens, separating static portions 293 # Parses the template and returns a set of tokens, separating static portions
294 # of text from binding declarations. 294 # of text from binding declarations.
295 @parse: (template) -> 295 @parse: (template, delimiters) ->
296 tokens = [] 296 tokens = []
297 length = template.length 297 length = template.length
298 index = 0 298 index = 0
299 lastIndex = 0 299 lastIndex = 0
300 300
301 while lastIndex < length 301 while lastIndex < length
302 index = template.indexOf '{{', lastIndex 302 index = template.indexOf delimiters[0], lastIndex
303 303
304 if index < 0 304 if index < 0
305 tokens.push type: @types.text, value: template.slice lastIndex 305 tokens.push type: @types.text, value: template.slice lastIndex
...@@ -309,7 +309,7 @@ class Rivets.TextTemplateParser ...@@ -309,7 +309,7 @@ class Rivets.TextTemplateParser
309 tokens.push type: @types.text, value: template.slice lastIndex, index 309 tokens.push type: @types.text, value: template.slice lastIndex, index
310 310
311 lastIndex = index + 2 311 lastIndex = index + 2
312 index = template.indexOf '}}', lastIndex 312 index = template.indexOf delimiters[1], lastIndex
313 313
314 if index < 0 314 if index < 0
315 substring = template.slice lastIndex - 2 315 substring = template.slice lastIndex - 2
......