Просмотр исходного кода

Preserve empty newlines

tags/0.5.1
Michael Jackson 14 лет назад
Родитель
Сommit
cf9031c76f
5 измененных файлов: 18 добавлений и 2 удалений
  1. +5
    -2
      mustache.js
  2. +1
    -0
      spec/_files/recursion_with_same_names.txt
  3. +4
    -0
      spec/_files/whitespace.js
  4. +4
    -0
      spec/_files/whitespace.mustache
  5. +4
    -0
      spec/_files/whitespace.txt

+ 5
- 2
mustache.js Просмотреть файл

@@ -216,13 +216,14 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
'\nsend("'
];

var spaces = [], // indices of whitespace in code for the current line
var spaces = [], // indices of whitespace in code on the current line
hasTag = false, // is there a {{tag}} on the current line?
nonSpace = false; // is there a non-space char on the current line?

// Strips all space characters from the code array for the current line
// if there was a {{tag}} on it and otherwise only spaces.
var stripSpace = function () {
if (!nonSpace && !options.space) {
if (hasTag && !nonSpace && !options.space) {
while (spaces.length) {
code.splice(spaces.pop(), 1);
}
@@ -230,6 +231,7 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
spaces = [];
}

hasTag = false;
nonSpace = false;
};

@@ -330,6 +332,7 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
updateLine = '\nline = ' + line + ';';
nextOpenTag = openTag;
nextCloseTag = closeTag;
hasTag = true;

switch (c) {
case "!": // comment


+ 1
- 0
spec/_files/recursion_with_same_names.txt Просмотреть файл

@@ -1,5 +1,6 @@
name
desc

t1
0
t2


+ 4
- 0
spec/_files/whitespace.js Просмотреть файл

@@ -0,0 +1,4 @@
var whitespace = {
tag1: "Hello",
tag2: "World"
};

+ 4
- 0
spec/_files/whitespace.mustache Просмотреть файл

@@ -0,0 +1,4 @@
{{tag1}}


{{tag2}}.

+ 4
- 0
spec/_files/whitespace.txt Просмотреть файл

@@ -0,0 +1,4 @@
Hello


World.

Загрузка…
Отмена
Сохранить