remove "using" param name

This commit is contained in:
Yonas Kolb
2018-04-30 12:00:54 +10:00
parent 7679b48164
commit 098af2a7b6
2 changed files with 5 additions and 5 deletions

View File

@@ -8,11 +8,11 @@ class IncludeNode : NodeType {
class func parse(_ parser: TokenParser, token: Token) throws -> NodeType { class func parse(_ parser: TokenParser, token: Token) throws -> NodeType {
let bits = token.components() let bits = token.components()
guard bits.count == 2 || (bits.count == 4 && bits[2] == "using") else { guard bits.count == 2 || bits.count == 3 else {
throw TemplateSyntaxError("'include' tag requires one argument, the template file to be included. Another optional argument can be used to specify the context that will be passed to the included file, using the format \"using myContext\"") throw TemplateSyntaxError("'include' tag requires one argument, the template file to be included. A second optional argument can be used to specify the context that will be passed to the included file")
} }
return IncludeNode(templateName: Variable(bits[1]), includeContext: bits.count == 4 ? bits[3] : nil) return IncludeNode(templateName: Variable(bits[1]), includeContext: bits.count == 3 ? bits[2] : nil)
} }
init(templateName: Variable, includeContext: String? = nil) { init(templateName: Variable, includeContext: String? = nil) {

View File

@@ -14,7 +14,7 @@ func testInclude() {
let tokens: [Token] = [ .block(value: "include") ] let tokens: [Token] = [ .block(value: "include") ]
let parser = TokenParser(tokens: tokens, environment: Environment()) let parser = TokenParser(tokens: tokens, environment: Environment())
let error = TemplateSyntaxError("'include' tag requires one argument, the template file to be included. Another optional argument can be used to specify the context that will be passed to the included file, using the format \"using myContext\"") let error = TemplateSyntaxError("'include' tag requires one argument, the template file to be included. A second optional argument can be used to specify the context that will be passed to the included file")
try expect(try parser.parse()).toThrow(error) try expect(try parser.parse()).toThrow(error)
} }
@@ -58,7 +58,7 @@ func testInclude() {
} }
$0.it("successfully passes context") { $0.it("successfully passes context") {
let template = Template(templateString: "{% include \"test.html\" using child %}") let template = Template(templateString: "{% include \"test.html\" child %}")
let context = Context(dictionary: ["child": ["target": "World"]], environment: environment) let context = Context(dictionary: ["child": ["target": "World"]], environment: environment)
let value = try template.render(context) let value = try template.render(context)
try expect(value) == "Hello World!" try expect(value) == "Hello World!"