diff --git a/Sources/HummingbirdMustache/Template+Parser.swift b/Sources/HummingbirdMustache/Template+Parser.swift index 72ceb7e..4d7e0f9 100644 --- a/Sources/HummingbirdMustache/Template+Parser.swift +++ b/Sources/HummingbirdMustache/Template+Parser.swift @@ -343,6 +343,7 @@ extension HBMustacheTemplate { guard try parser.read(":") else { throw Error.invalidConfigVariableSyntax } parser.read(while: \.isWhitespace) value = parser.read(while: self.sectionNameCharsWithoutBrackets) + parser.read(while: \.isWhitespace) guard try parser.read(string: state.endDelimiter) else { throw Error.invalidConfigVariableSyntax } } catch { throw Error.invalidConfigVariableSyntax diff --git a/Tests/HummingbirdMustacheTests/TemplateParserTests.swift b/Tests/HummingbirdMustacheTests/TemplateParserTests.swift index 83b9587..f7e7f08 100644 --- a/Tests/HummingbirdMustacheTests/TemplateParserTests.swift +++ b/Tests/HummingbirdMustacheTests/TemplateParserTests.swift @@ -34,7 +34,13 @@ final class TemplateParserTests: XCTestCase { func testContentType() throws { 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(template1.tokens, [.contentType(HBTextContentType())]) + XCTAssertEqual(template2.tokens, [.contentType(HBTextContentType())]) + XCTAssertEqual(template3.tokens, [.contentType(HBTextContentType())]) } }