Skip to content

Instantly share code, notes, and snippets.

@InukVT
Last active April 9, 2019 08:32
Show Gist options
  • Select an option

  • Save InukVT/39437ffd620ffd4d1bdb753478f9ee99 to your computer and use it in GitHub Desktop.

Select an option

Save InukVT/39437ffd620ffd4d1bdb753478f9ee99 to your computer and use it in GitHub Desktop.
// ..
services.register { container -> LeafTagConfig in
var config = LeafTagConfig.default()
config.use(LeafSplash(), as: "splash")
return config
}
// ..
import Foundation
import Splash
import Leaf
final class LeafSplash: TagRenderer {
init() { }
func render(code: TagContext) throws -> EventLoopFuture<TemplateData> {
let highlighter = SyntaxHighlighter(format: HTMLOutputFormat())
let string = highlighter.highlight(code)
return tag.container.future(.string(string))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment