Permalink
Browse files

fixed problem with trailing text not being added to template

  • Loading branch information...
justinbmeyer committed Jun 19, 2012
1 parent 656acd2 commit 419248bf190febe5c3ccacb188e9c812e997278e
Showing with 15 additions and 5 deletions.
  1. +9 −4 view/ejs/ejs.js
  2. +6 −1 view/ejs/ejs_test.js
View
@@ -413,14 +413,19 @@ steal('can/view', 'can/util/string','can/observe/compute').then(function( $ ) {
source = source.replace(newLine, "\n");
source.replace(tokenReg, function(whole, part, offset){
+ // if the next token starts after the last token ends
+ // push what's in between
if(offset > last){
tokens.push( source.substring(last, offset) );
- }
- tokens.push(part)
+ }
+ // push the token
+ tokens.push(part);
+ // update the position of the last part of the last token
last = offset+part.length;
})
- if(last === 0){
- tokens.push(source)
+ // if there's something at the end, add it
+ if(last < source.length){
+ tokens.push(source.substr(last))
}
var content = '',
View
@@ -816,6 +816,11 @@ test("nested live bindings", function(){
})*/
-
+test("trailing text", function(){
+ can.view.ejs("count","There are <%= this.attr('length') %> todos")
+ var div = document.createElement('div');
+ div.appendChild( can.view("count", new can.Observe.List([{},{}])) );
+ ok(/There are 2 todos/.test(div.innerHTML), "got all text")
+})
})()

0 comments on commit 419248b

Please sign in to comment.