replaced Token with Lexeme protocol on TemplateSyntaxError

This commit is contained in:
Ilya Puchka
2017-10-07 20:54:42 +02:00
parent 6300dbc7bf
commit 69cd8e4d3b
6 changed files with 52 additions and 69 deletions

View File

@@ -68,17 +68,8 @@ open class Template: ExpressibleByStringLiteral {
func render(_ context: Context) throws -> String {
let context = context
let parser = TokenParser(tokens: tokens, environment: context.environment)
do {
let nodes = try parser.parse()
return try renderNodes(nodes, context)
} catch {
if let syntaxError = error as? TemplateSyntaxError,
let error = syntaxError.contextAwareError(templateName: name, templateContent: templateString) {
throw error
} else {
throw error
}
}
let nodes = try parser.parse()
return try renderNodes(nodes, context)
}
/// Render the given template