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

@@ -19,16 +19,15 @@ class IncludeNode : NodeType {
}
func render(_ context: Context) throws -> String {
guard let loader = context["loader"] as? Loader else {
throw TemplateSyntaxError("Template loader not in context")
}
guard let templateName = try self.templateName.resolve(context) as? String else {
throw TemplateSyntaxError("'\(self.templateName)' could not be resolved as a string")
}
let template = try loader.loadTemplate(name: templateName)
return try template.render(context)
let template = try context.environment.loadTemplate(name: templateName)
return try context.push {
return try template.render(context)
}
}
}