Browse Source

added test for when partials are retrieved via a function

pull/619/head
connor 9 years ago
parent
commit
edbfaaf1ba
5 changed files with 14 additions and 1 deletions
  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 View File

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

+ 1
- 0
test/_files/partial_function.mustache View File

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

+ 1
- 0
test/_files/partial_function.partial View File

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

+ 1
- 0
test/_files/partial_function.txt View File

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

+ 7
- 1
test/render-test.js View File

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


Loading…
Cancel
Save