【发布时间】:2021-12-14 17:42:45
【问题描述】:
我使用了一个版本的 Leaf 来加载 .html 文件,而不是我的 Vapor 项目中的 .leaf 文件,它可以自动为这些相同的文件进行语法着色。
Leaf 的版本是4.0.0-tau.1,LeafKit 的版本是1.0.0-tau.1.1
当使用这个特定版本时,我可以通过这种方式在configure.swift 文件中设置叶子:
/// Change the classic .leaf extension to .html for the syntax
/// coloring option of Xcode to work each time the app is being load up.
fileprivate func leaf(_ app: Application) {
if !app.environment.isRelease {
LeafRenderer.Option.caching = .bypass // Another issue from the update
}
let detected = LeafEngine.rootDirectory ?? app.directory.viewsDirectory
LeafEngine.rootDirectory = detected
LeafEngine.sources = .singleSource(
NIOLeafFiles(fileio: app.fileio,
limits: .default,
sandboxDirectory: detected,
viewDirectory: detected,
defaultExtension: "html"))
app.views.use(.leaf)
}
在此代码中,LeafRenderer.Option.caching = .bypass 和与 LeafEngine 一起使用的代码不再起作用,因为已将 Leaf 更新为 4.1.3 并将 LeafKit 更新为 1.3.1。
如何使用更新的 Leaf 和 LeafKit 框架成功地使此代码像以前一样工作?
【问题讨论】: