繁体   English   中英

不使用 tau 版本时如何使用 Leaf 读取 Vapor 上的 html 文件?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM