refactor: Introducing Environments

This commit is contained in:
Kyle Fuller
2016-12-01 00:17:04 +00:00
parent 2be672c6a5
commit 9e2a061795
27 changed files with 289 additions and 91 deletions

View File

@@ -7,17 +7,16 @@ func testInheritence() {
describe("Inheritence") {
let path = Path(#file) + ".." + "fixtures"
let loader = FileSystemLoader(paths: [path])
let environment = Environment(loader: loader)
$0.it("can inherit from another template") {
let context = Context(dictionary: ["loader": loader])
let template = try loader.loadTemplate(name: "child.html")
try expect(try template.render(context)) == "Header\nChild"
let template = try environment.loadTemplate(name: "child.html")
try expect(try template.render()) == "Header\nChild"
}
$0.it("can inherit from another template inheriting from another template") {
let context = Context(dictionary: ["loader": loader])
let template = try loader.loadTemplate(name: "child-child.html")
try expect(try template.render(context)) == "Child Child Header\nChild"
let template = try environment.loadTemplate(name: "child-child.html")
try expect(try template.render()) == "Child Child Header\nChild"
}
}
}