Last active
April 9, 2019 08:32
-
-
Save InukVT/39437ffd620ffd4d1bdb753478f9ee99 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // .. | |
| services.register { container -> LeafTagConfig in | |
| var config = LeafTagConfig.default() | |
| config.use(LeafSplash(), as: "splash") | |
| return config | |
| } | |
| // .. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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