Got carriage returns working.

This commit is contained in:
Alan Johnson
2010-09-13 20:30:15 -04:00
parent ed5f10c282
commit 281e45d6ba
2 changed files with 8 additions and 0 deletions
+3
View File
@@ -231,6 +231,9 @@ Handlebars.Compiler.prototype = {
if(chr === "\n") {
this.newlines = this.newlines + "\n";
chr = "\\n";
} else if (chr === "\r") {
this.newlines = this.newlines + "\r";
chr = "\\r";
}
this.text = this.text + chr;
}
+5
View File
@@ -26,6 +26,11 @@ test("boolean", function() {
"booleans do not show the contents when false");
});
test("newlines", function() {
shouldCompileTo("Alan's\nTest", {}, "Alan's\nTest");
shouldCompileTo("Alan's\rTest", {}, "Alan's\rTest");
});
test("escaping text", function() {
shouldCompileTo("Awesome's", {}, "Awesome's", "text is escaped so that it doesn't get caught on single quotes");
shouldCompileTo("Awesome\\", {}, "Awesome\\", "text is escaped so that the closing quote can't be ignored");