瀏覽代碼

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;
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>

Loading…
取消
儲存