Created
June 27, 2012 01:07
-
-
Save MattCheely/3000611 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
Primary Book | |
Primary Book | |
Primary Book |
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
{{title}} |
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
Primary Book | |
Related Book 1 | |
Related Book 2 |
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
@Test | |
public void testSurprisingBehavior() throws Exception { | |
final class Book { | |
public String title; | |
public Book(String title) { | |
this.title = title; | |
} | |
} | |
Map<String, Object> model = new HashMap<String, Object>(); | |
model.put("book", new Book("Primary Book")); | |
List<Book> relatedBooks = new ArrayList<Book>(); | |
relatedBooks.add(new Book("Related Book 1")); | |
relatedBooks.add(new Book("Related Book 2")); | |
model.put("relatedBooks", relatedBooks); | |
MustacheFactory factory = new DefaultMustacheFactory(root); | |
Mustache stache = factory.compile("unexpected.html"); | |
StringWriter writer = new StringWriter(); | |
stache.execute(writer, model); | |
assertEquals(getContents(root, "expectedOutput.txt"), writer.toString()); | |
} |
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
{{book.title}} | |
{{#relatedBooks}} | |
{{> book}} | |
{{/relatedBooks}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment