Allow for space after value in {{%var:value}}
This commit is contained in:
@@ -343,6 +343,7 @@ extension HBMustacheTemplate {
|
|||||||
guard try parser.read(":") else { throw Error.invalidConfigVariableSyntax }
|
guard try parser.read(":") else { throw Error.invalidConfigVariableSyntax }
|
||||||
parser.read(while: \.isWhitespace)
|
parser.read(while: \.isWhitespace)
|
||||||
value = parser.read(while: self.sectionNameCharsWithoutBrackets)
|
value = parser.read(while: self.sectionNameCharsWithoutBrackets)
|
||||||
|
parser.read(while: \.isWhitespace)
|
||||||
guard try parser.read(string: state.endDelimiter) else { throw Error.invalidConfigVariableSyntax }
|
guard try parser.read(string: state.endDelimiter) else { throw Error.invalidConfigVariableSyntax }
|
||||||
} catch {
|
} catch {
|
||||||
throw Error.invalidConfigVariableSyntax
|
throw Error.invalidConfigVariableSyntax
|
||||||
|
|||||||
@@ -34,7 +34,13 @@ final class TemplateParserTests: XCTestCase {
|
|||||||
|
|
||||||
func testContentType() throws {
|
func testContentType() throws {
|
||||||
let template = try HBMustacheTemplate(string: "{{% CONTENT_TYPE:TEXT}}")
|
let template = try HBMustacheTemplate(string: "{{% CONTENT_TYPE:TEXT}}")
|
||||||
|
let template1 = try HBMustacheTemplate(string: "{{% CONTENT_TYPE:TEXT }}")
|
||||||
|
let template2 = try HBMustacheTemplate(string: "{{% CONTENT_TYPE: TEXT}}")
|
||||||
|
let template3 = try HBMustacheTemplate(string: "{{%CONTENT_TYPE:TEXT}}")
|
||||||
XCTAssertEqual(template.tokens, [.contentType(HBTextContentType())])
|
XCTAssertEqual(template.tokens, [.contentType(HBTextContentType())])
|
||||||
|
XCTAssertEqual(template1.tokens, [.contentType(HBTextContentType())])
|
||||||
|
XCTAssertEqual(template2.tokens, [.contentType(HBTextContentType())])
|
||||||
|
XCTAssertEqual(template3.tokens, [.contentType(HBTextContentType())])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user