[英]How to read html files on Vapor with Leaf when not using the tau version?
有一個 Leaf 版本,我用來從我的 Vapor 項目加載 .html 文件而不是 .leaf 文件,它可以自動完成相同文件的語法着色。
Leaf 的版本是4.0.0-tau.1
,LeafKit 的版本是1.0.0-tau.1.1
使用此特定版本時,我可以通過以下方式在configure.swift
文件中設置 Leaf:
/// 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
由於具有更新的葉不工作了4.1.3
和LeafKit到1.3.1
。
如何使用更新的 Leaf 和 LeafKit 框架成功地使此代碼像以前一樣工作?
你可以使用這個 Xcode 插件: https : //github.com/OmranK/VaporLeafPlugIn
它為 Xcode IDE 添加了 Vapor Leaf 語言支持。 為 Leaf 標簽以及帶有自動縮進的 HTML 標簽提供語法高亮。
目前該插件最多支持 Xcode 13.2 beta。 未來的 Xcode 版本將需要小的更新(添加新的 DVTPlugInCompatibilityUUID),但即使在已經安裝的插件上也可以輕松處理。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.