Created
June 27, 2011 19:04
-
-
Save chrisconley/1049557 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Both tests fail with `view.$().text()` being empty. | |
test("should pass content as context when using {{#each}} helper within {{#with}} helper", function() { | |
var view = SC.View.create({ | |
template: SC.Handlebars.compile('{{#with content}}{{#each releases}}Mac OS X {{version}}: {{name}} {{/each}}{{/with}}'), | |
content: { | |
releases: [ { version: '10.7', | |
name: 'Lion' }, | |
{ version: '10.6', | |
name: 'Snow Leopard' }, | |
{ version: '10.5', | |
name: 'Leopard' } ] | |
} | |
}); | |
SC.run(function() { view.append(); }); | |
equals(view.$().text(), "Mac OS X 10.7: Lion Mac OS X 10.6: Snow Leopard Mac OS X 10.5: Leopard ", "prints each item in sequence"); | |
}); | |
test("should pass content as context when using {{#each}} helper within {{#if}} helper", function() { | |
var view = SC.View.create({ | |
template: SC.Handlebars.compile('{{#if content}}{{#each content.releases}}Mac OS X {{version}}: {{name}} {{/each}}{{/if}}'), | |
content: { | |
releases: [ { version: '10.7', | |
name: 'Lion' }, | |
{ version: '10.6', | |
name: 'Snow Leopard' }, | |
{ version: '10.5', | |
name: 'Leopard' } ] | |
} | |
}); | |
SC.run(function() { view.append(); }); | |
equals(view.$().text(), "Mac OS X 10.7: Lion Mac OS X 10.6: Snow Leopard Mac OS X 10.5: Leopard ", "prints each item in sequence"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment