ソースを参照

Merge edbfaaf1ba into 1a244cbbd9

pull/619/merge
Connor Taylor GitHub 6年前
コミット
83e2adead8
この署名に対応する既知のキーがデータベースに存在しません GPGキーID: 4AEE18F83AFDEB23
6個のファイルの変更17行の追加2行の削除
  1. +3
    -1
      mustache.js
  2. +4
    -0
      test/_files/partial_function.js
  3. +1
    -0
      test/_files/partial_function.mustache
  4. +1
    -0
      test/_files/partial_function.partial
  5. +1
    -0
      test/_files/partial_function.txt
  6. +7
    -1
      test/render-test.js

+ 3
- 1
mustache.js ファイルの表示

@@ -595,7 +595,9 @@
Writer.prototype.renderPartial = function renderPartial (token, context, partials, tags) {
if (!partials) return;

var value = isFunction(partials) ? partials(token[1]) : partials[token[1]];
var value = isFunction(partials)
? partials(token[1], context.view)
: partials[token[1]];
if (value != null)
return this.renderTokens(this.parse(value, tags), context, partials, value);
};


+ 4
- 0
test/_files/partial_function.js ファイルの表示

@@ -0,0 +1,4 @@
({
id: 'main',
value: 'foo'
})

+ 1
- 0
test/_files/partial_function.mustache ファイルの表示

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

+ 1
- 0
test/_files/partial_function.partial ファイルの表示

@@ -0,0 +1 @@
{{id}}: {{value}}

+ 1
- 0
test/_files/partial_function.txt ファイルの表示

@@ -0,0 +1 @@
main: foo

+ 7
- 1
test/render-test.js ファイルの表示

@@ -65,7 +65,13 @@ describe('Mustache.render', function () {
it('knows how to render ' + test.name, function () {
var output;
if (test.partial) {
output = Mustache.render(test.template, view, { partial: test.partial });
// Ensure partials can be retreived via an object or a function
// See Writer.prototype.renderPartial
var partial = test.name === 'partial_function'
? function (partial, context) { return test.partial }
: { partial: test.partial };

output = Mustache.render(test.template, view, partial);
} else {
output = Mustache.render(test.template, view);
}


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