Przeglądaj źródła

Merge remote-tracking branch 'upstream/master'

tags/0.5.2
Michael Jackson 13 lat temu
rodzic
commit
dbf609fd37
2 zmienionych plików z 8 dodań i 8 usunięć
  1. +7
    -7
      mustache.js
  2. +1
    -1
      package.json

+ 7
- 7
mustache.js Wyświetl plik

@@ -221,6 +221,10 @@ var Mustache;
}; };


Renderer.prototype.compile = function (tokens, tags) { Renderer.prototype.compile = function (tokens, tags) {
if (typeof tokens === "string") {
tokens = parse(tokens, tags);
}

var fn = compileTokens(tokens), var fn = compileTokens(tokens),
self = this; self = this;


@@ -260,7 +264,7 @@ var Mustache;
return buffer; return buffer;
} }


return callback(context.push(value), this);
return value ? callback(context.push(value), this) : "";
case "function": case "function":
// TODO: The text should be passed to the callback plain, not rendered. // TODO: The text should be passed to the callback plain, not rendered.
var sectionText = callback(context, this), var sectionText = callback(context, this),
@@ -326,10 +330,6 @@ var Mustache;
* `returnBody` is true. * `returnBody` is true.
*/ */
function compileTokens(tokens, returnBody) { function compileTokens(tokens, returnBody) {
if (typeof tokens === "string") {
tokens = parse(tokens);
}

var body = ['""']; var body = ['""'];
var token, method, escape; var token, method, escape;


@@ -465,8 +465,8 @@ var Mustache;
*/ */
function parse(template, tags) { function parse(template, tags) {
tags = tags || exports.tags; tags = tags || exports.tags;
var tagRes = escapeTags(tags);


var tagRes = escapeTags(tags);
var scanner = new Scanner(template); var scanner = new Scanner(template);


var tokens = [], // Buffer to hold the tokens var tokens = [], // Buffer to hold the tokens
@@ -496,7 +496,7 @@ var Mustache;


if (value) { if (value) {
for (var i = 0, len = value.length; i < len; ++i) { for (var i = 0, len = value.length; i < len; ++i) {
chr = value[i];
chr = value.charAt(i);


if (isWhitespace(chr)) { if (isWhitespace(chr)) {
spaces.push(tokens.length); spaces.push(tokens.length);


+ 1
- 1
package.json Wyświetl plik

@@ -4,7 +4,7 @@
"description": "Logic-less {{mustache}} templates with JavaScript", "description": "Logic-less {{mustache}} templates with JavaScript",
"author": "mustache.js Authors <http://github.com/janl/mustache.js>", "author": "mustache.js Authors <http://github.com/janl/mustache.js>",
"keywords": ["mustache", "template", "templates", "ejs"], "keywords": ["mustache", "template", "templates", "ejs"],
"main": "./mustache",
"main": "./mustache.js",
"devDependencies": { "devDependencies": {
"vows": "0.6.x", "vows": "0.6.x",
"uglify-js": "1.3.0" "uglify-js": "1.3.0"


Ładowanie…
Anuluj
Zapisz