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

clean up some logic

tags/0.4.0
Ben Cherry 15 лет назад
Родитель
Сommit
90bc5a9a84
1 измененных файлов: 21 добавлений и 15 удалений
  1. +21
    -15
      mustache.js

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

@@ -40,28 +40,24 @@ var Mustache = function() {
context['_mode'] = this.pragmas['TRANSLATION-HINT']['mode'];
}

// get the pragmas together
template = this.render_pragmas(template);

// handle all translations
template = this.render_i18n(template, context, partials);

// render the template
var html = this.render_section(template, context, partials);

if (html === template) {
if (in_recursion) {
return this.render_tags(html, context, partials, true);
}
// render_section did not find any sections, we still need to render the tags
if (html === false) {
html = this.render_tags(template, context, partials, in_recursion);
}

this.render_tags(html, context, partials, false);
if (in_recursion) {
return html;
} else {
if(in_recursion) {
return html;
} else {
var lines = html.split("\n");
for (var i = 0; i < lines.length; i++) {
this.send(lines[i]);
}
return;
}
this.sendLines(html);
}
},

@@ -74,6 +70,15 @@ var Mustache = function() {
}
},

sendLines: function(text) {
if (text) {
var lines = text.split("\n");
for (var i = 0; i < lines.length; i++) {
this.send(lines[i]);
}
}
},

/*
Looks for %PRAGMAS
*/
@@ -142,7 +147,8 @@ var Mustache = function() {
*/
render_section: function(template, context, partials) {
if(!this.includes("#", template) && !this.includes("^", template)) {
return template;
// did not render anything, there were no sections
return false;
}

var that = this;


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