ソースを参照

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

tags/0.8.1
Lakshan Perera Michael Jackson 12年前
コミット
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; break;
case '>': case '>':
if (!partials) continue; 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; break;
case '&': case '&':
value = context.lookup(token[1]); 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>

読み込み中…
キャンセル
保存