fix rendering templates created from string literals

This commit is contained in:
Ilya Puchka
2017-12-26 21:20:09 +01:00
parent ed885f462a
commit abeb30bb1c
2 changed files with 3 additions and 1 deletions

View File

@@ -43,6 +43,8 @@ public struct Environment {
}
func render(template: Template, context: [String: Any]?) throws -> String {
// update temaplte environment as it cen be created from string literal with default environment
template.environment = self
errorReporter.context = ErrorReporterContext(template: template)
do {
return try template.render(context)

View File

@@ -8,7 +8,7 @@ let NSFileNoSuchFileError = 4
/// A class representing a template
open class Template: ExpressibleByStringLiteral {
let templateString: String
let environment: Environment
internal(set) var environment: Environment
let tokens: [Token]
/// The name of the loaded Template if the Template was loaded from a Loader