Add / as a valid partialNameChar and use it in parse (#71)
* Add / as a valid partialNameChar and use it in parse * maybe let's not keep "bla" in the tests
This commit is contained in:
@@ -441,7 +441,7 @@ extension MustacheTemplate {
|
||||
/// parse partial name
|
||||
static func parsePartialName(_ parser: inout Parser, state: ParserState) throws -> String {
|
||||
parser.read(while: \.isWhitespace)
|
||||
let text = String(parser.read(while: self.sectionNameChars))
|
||||
let text = String(parser.read(while: self.partialNameChars))
|
||||
parser.read(while: \.isWhitespace)
|
||||
guard try parser.read(string: state.endDelimiter) else { throw Error.unfinishedName }
|
||||
return text
|
||||
@@ -518,5 +518,5 @@ extension MustacheTemplate {
|
||||
|
||||
private static let sectionNameCharsWithoutBrackets = Set<Character>("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-_?*")
|
||||
private static let sectionNameChars = Set<Character>("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-_?()*")
|
||||
private static let partialNameChars = Set<Character>("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-_()")
|
||||
private static let partialNameChars = Set<Character>("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-_?()*/")
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ final class PartialTests: XCTestCase {
|
||||
string: """
|
||||
<h2>Names</h2>
|
||||
{{#names}}
|
||||
{{> user}}
|
||||
{{> us/er}}
|
||||
{{/names}}
|
||||
"""
|
||||
)
|
||||
@@ -33,7 +33,7 @@ final class PartialTests: XCTestCase {
|
||||
|
||||
"""
|
||||
)
|
||||
let library = MustacheLibrary(templates: ["base": template, "user": template2])
|
||||
let library = MustacheLibrary(templates: ["base": template, "us/er": template2])
|
||||
|
||||
let object: [String: Any] = ["names": ["john", "adam", "claire"]]
|
||||
XCTAssertEqual(
|
||||
|
||||
Reference in New Issue
Block a user