fix rendering templates created from string literals
This commit is contained in:
@@ -43,6 +43,8 @@ public struct Environment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func render(template: Template, context: [String: Any]?) throws -> String {
|
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)
|
errorReporter.context = ErrorReporterContext(template: template)
|
||||||
do {
|
do {
|
||||||
return try template.render(context)
|
return try template.render(context)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ let NSFileNoSuchFileError = 4
|
|||||||
/// A class representing a template
|
/// A class representing a template
|
||||||
open class Template: ExpressibleByStringLiteral {
|
open class Template: ExpressibleByStringLiteral {
|
||||||
let templateString: String
|
let templateString: String
|
||||||
let environment: Environment
|
internal(set) var environment: Environment
|
||||||
let tokens: [Token]
|
let tokens: [Token]
|
||||||
|
|
||||||
/// The name of the loaded Template if the Template was loaded from a Loader
|
/// The name of the loaded Template if the Template was loaded from a Loader
|
||||||
|
|||||||
Reference in New Issue
Block a user