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

added test for when partials are retrieved via a function

pull/619/head
connor 9 лет назад
Родитель
Сommit
edbfaaf1ba
5 измененных файлов: 14 добавлений и 1 удалений
  1. +4
    -0
      test/_files/partial_function.js
  2. +1
    -0
      test/_files/partial_function.mustache
  3. +1
    -0
      test/_files/partial_function.partial
  4. +1
    -0
      test/_files/partial_function.txt
  5. +7
    -1
      test/render-test.js

+ 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 Просмотреть файл

@@ -23,7 +23,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);
}


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