Add transforms empty() and equalzero()

This commit is contained in:
Adam Fowler
2021-03-23 18:17:44 +00:00
parent 40ef59c897
commit f7bd02267e
2 changed files with 14 additions and 0 deletions

View File

@@ -128,6 +128,14 @@ final class TransformTests: XCTestCase {
""")
}
func testDictionaryEmpty() throws {
let template = try HBMustacheTemplate(string: """
{{#empty(array)}}Array{{/empty(array)}}{{#empty(dictionary)}}Dictionary{{/empty(dictionary)}}
""")
let object: [String: Any] = ["array":[], "dictionary":[:]]
XCTAssertEqual(template.render(object), "ArrayDictionary")
}
func testListOutput() throws {
let object = [1, 2, 3, 4]
let template = try HBMustacheTemplate(string: "{{#.}}{{.}}{{^last()}}, {{/last()}}{{/.}}")