removed unneeded error reporter references
This commit is contained in:
@@ -4,10 +4,6 @@ public class Context {
|
|||||||
|
|
||||||
public let environment: Environment
|
public let environment: Environment
|
||||||
|
|
||||||
public var errorReporter: ErrorReporter {
|
|
||||||
return environment.errorReporter
|
|
||||||
}
|
|
||||||
|
|
||||||
init(dictionary: [String: Any]? = nil, environment: Environment? = nil) {
|
init(dictionary: [String: Any]? = nil, environment: Environment? = nil) {
|
||||||
if let dictionary = dictionary {
|
if let dictionary = dictionary {
|
||||||
dictionaries = [dictionary]
|
dictionaries = [dictionary]
|
||||||
|
|||||||
@@ -3,15 +3,12 @@ public struct Environment {
|
|||||||
public var extensions: [Extension]
|
public var extensions: [Extension]
|
||||||
|
|
||||||
public var loader: Loader?
|
public var loader: Loader?
|
||||||
public var errorReporter: ErrorReporter
|
|
||||||
|
|
||||||
public init(loader: Loader? = nil,
|
public init(loader: Loader? = nil,
|
||||||
extensions: [Extension]? = nil,
|
extensions: [Extension]? = nil,
|
||||||
templateClass: Template.Type = Template.self,
|
templateClass: Template.Type = Template.self) {
|
||||||
errorReporter: ErrorReporter = SimpleErrorReporter()) {
|
|
||||||
|
|
||||||
self.templateClass = templateClass
|
self.templateClass = templateClass
|
||||||
self.errorReporter = errorReporter
|
|
||||||
self.loader = loader
|
self.loader = loader
|
||||||
self.extensions = (extensions ?? []) + [DefaultExtension()]
|
self.extensions = (extensions ?? []) + [DefaultExtension()]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,8 @@ func testEnvironment() {
|
|||||||
|
|
||||||
let error = try expect(environment.render(template: template, context: ["names": ["Bob", "Alice"], "name": "Bob"]),
|
let error = try expect(environment.render(template: template, context: ["names": ["Bob", "Alice"], "name": "Bob"]),
|
||||||
file: file, line: line, function: function).toThrow() as TemplateSyntaxError
|
file: file, line: line, function: function).toThrow() as TemplateSyntaxError
|
||||||
try expect(environment.errorReporter.renderError(error), file: file, line: line, function: function) == environment.errorReporter.renderError(expectedError)
|
let reporter = SimpleErrorReporter()
|
||||||
|
try expect(reporter.renderError(error), file: file, line: line, function: function) == reporter.renderError(expectedError)
|
||||||
}
|
}
|
||||||
|
|
||||||
$0.context("given syntax error") {
|
$0.context("given syntax error") {
|
||||||
@@ -209,7 +210,8 @@ func testEnvironment() {
|
|||||||
|
|
||||||
let error = try expect(environment.render(template: template, context: ["target": "World"]),
|
let error = try expect(environment.render(template: template, context: ["target": "World"]),
|
||||||
file: file, line: line, function: function).toThrow() as TemplateSyntaxError
|
file: file, line: line, function: function).toThrow() as TemplateSyntaxError
|
||||||
try expect(environment.errorReporter.renderError(error), file: file, line: line, function: function) == environment.errorReporter.renderError(expectedError)
|
let reporter = SimpleErrorReporter()
|
||||||
|
try expect(reporter.renderError(error), file: file, line: line, function: function) == reporter.renderError(expectedError)
|
||||||
}
|
}
|
||||||
|
|
||||||
$0.it("reports syntax error in included template") {
|
$0.it("reports syntax error in included template") {
|
||||||
@@ -259,7 +261,8 @@ func testEnvironment() {
|
|||||||
}
|
}
|
||||||
let error = try expect(environment.render(template: childTemplate, context: ["target": "World"]),
|
let error = try expect(environment.render(template: childTemplate, context: ["target": "World"]),
|
||||||
file: file, line: line, function: function).toThrow() as TemplateSyntaxError
|
file: file, line: line, function: function).toThrow() as TemplateSyntaxError
|
||||||
try expect(environment.errorReporter.renderError(error), file: file, line: line, function: function) == environment.errorReporter.renderError(expectedError)
|
let reporter = SimpleErrorReporter()
|
||||||
|
try expect(reporter.renderError(error), file: file, line: line, function: function) == reporter.renderError(expectedError)
|
||||||
}
|
}
|
||||||
|
|
||||||
$0.it("reports syntax error in base template") {
|
$0.it("reports syntax error in base template") {
|
||||||
|
|||||||
@@ -232,8 +232,8 @@ func testFilter() {
|
|||||||
|
|
||||||
let error = try expect(environment.render(template: template, context: [:]),
|
let error = try expect(environment.render(template: template, context: [:]),
|
||||||
file: file, line: line, function: function).toThrow() as TemplateSyntaxError
|
file: file, line: line, function: function).toThrow() as TemplateSyntaxError
|
||||||
|
let reporter = SimpleErrorReporter()
|
||||||
try expect(environment.errorReporter.renderError(error), file: file, line: line, function: function) == environment.errorReporter.renderError(expectedError)
|
try expect(reporter.renderError(error), file: file, line: line, function: function) == reporter.renderError(expectedError)
|
||||||
}
|
}
|
||||||
|
|
||||||
$0.it("made for unknown filter") {
|
$0.it("made for unknown filter") {
|
||||||
|
|||||||
Reference in New Issue
Block a user