diff --git a/Sources/Mustache/Library+FileSystem.swift b/Sources/Mustache/Library+FileSystem.swift
index 1769f1b..1396e25 100644
--- a/Sources/Mustache/Library+FileSystem.swift
+++ b/Sources/Mustache/Library+FileSystem.swift
@@ -31,7 +31,11 @@ extension MustacheLibrary {
guard let template = try MustacheTemplate(filename: directory + path) else { continue }
// drop ".mustache" from path to get name
let name = String(path.dropLast(extWithDot.count))
+ #if os(Windows)
+ templates[name.replacingOccurrences(of: "\\", with: "/")] = template
+ #else
templates[name] = template
+ #endif
} catch let error as MustacheTemplate.ParserError {
throw ParserError(filename: path, context: error.context, error: error.error)
}
diff --git a/Tests/MustacheTests/LibraryTests.swift b/Tests/MustacheTests/LibraryTests.swift
index 7c9f370..6ccf2fb 100644
--- a/Tests/MustacheTests/LibraryTests.swift
+++ b/Tests/MustacheTests/LibraryTests.swift
@@ -48,6 +48,24 @@ final class LibraryTests: XCTestCase {
XCTAssertEqual(library.render(object, withTemplate: "test"), "value1value2")
}
+ func testPartialInSubfolder() async throws {
+ let fs = FileManager()
+ try? fs.createDirectory(atPath: "templates/subfolder", withIntermediateDirectories: true)
+ let mustache = Data("{{#value}}{{.}}{{/value}}".utf8)
+ try mustache.write(to: URL(fileURLWithPath: "templates/subfolder/test-partial.mustache"))
+ let mustache2 = Data("{{>subfolder/test-partial}}".utf8)
+ try mustache2.write(to: URL(fileURLWithPath: "templates/test.mustache"))
+ defer {
+ XCTAssertNoThrow(try fs.removeItem(atPath: "templates/subfolder/test-partial.mustache"))
+ XCTAssertNoThrow(try fs.removeItem(atPath: "templates/test.mustache"))
+ XCTAssertNoThrow(try fs.removeItem(atPath: "templates"))
+ }
+
+ let library = try await MustacheLibrary(directory: "./templates")
+ let object = ["value": ["value1", "value2"]]
+ XCTAssertEqual(library.render(object, withTemplate: "test"), "value1value2")
+ }
+
func testLibraryParserError() async throws {
let fs = FileManager()
try? fs.createDirectory(atPath: "templates", withIntermediateDirectories: false)