Partials path handling fixes

This commit is contained in:
Kyle Jessup 2016-10-07 11:03:50 -04:00
parent e919ded2ee
commit 6df2ee38a6
2 changed files with 9 additions and 2 deletions

1
.gitignore vendored
View File

@ -66,3 +66,4 @@ fastlane/test_output
Packages/
*.xcodeproj/
.DS_Store

View File

@ -411,8 +411,14 @@ public class MustachePartialTag : MustacheTag {
return
}
let withoutLast = page.deletingLastFilePathComponent
let slash = withoutLast[withoutLast.startIndex] == "/" ? "/" : ""
let pageDir = slash + withoutLast.characters.split(separator: "/").map(String.init).joined(separator: "/")
let pageDir: String
if withoutLast.isEmpty { // foo.mustache
pageDir = "."
} else if withoutLast.hasSuffix("/") {
pageDir = withoutLast
} else {
pageDir = "."
}
let fullPath = pageDir + "/" + self.tag + "." + mustacheExtension
do {
let template = try getTemplateFromCache(fullPath)