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

When rendering partials, pass the partial template instead of the original template.

tags/0.8.1
Lakshan Perera Michael Jackson 12 лет назад
Родитель
Сommit
42ec324c8f
5 измененных файлов: 17 добавлений и 2 удалений
  1. +3
    -2
      mustache.js
  2. +7
    -0
      test/_files/section_functions_in_partials.js
  3. +3
    -0
      test/_files/section_functions_in_partials.mustache
  4. +1
    -0
      test/_files/section_functions_in_partials.partial
  5. +3
    -0
      test/_files/section_functions_in_partials.txt

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

@@ -496,8 +496,9 @@
break;
case '>':
if (!partials) continue;
value = this.parse(isFunction(partials) ? partials(token[1]) : partials[token[1]]);
if (value != null) buffer += this.renderTokens(value, context, partials, originalTemplate);
var partialTemplate = isFunction(partials) ? partials(token[1]) : partials[token[1]];
value = this.parse(partialTemplate);
if (value != null) buffer += this.renderTokens(value, context, partials, partialTemplate);
break;
case '&':
value = context.lookup(token[1]);


+ 7
- 0
test/_files/section_functions_in_partials.js Просмотреть файл

@@ -0,0 +1,7 @@
({
bold: function(){
return function(text, render) {
return "<b>" + render(text) + "</b>";
}
}
})

+ 3
- 0
test/_files/section_functions_in_partials.mustache Просмотреть файл

@@ -0,0 +1,3 @@
{{> partial}}

<p>some more text</p>

+ 1
- 0
test/_files/section_functions_in_partials.partial Просмотреть файл

@@ -0,0 +1 @@
{{#bold}}Hello There{{/bold}}

+ 3
- 0
test/_files/section_functions_in_partials.txt Просмотреть файл

@@ -0,0 +1,3 @@
<b>Hello There</b>

<p>some more text</p>

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