https://github.com/skeyboy/vapormarkdown
vapor leaf 模版引擎的Markdown标签
https://github.com/skeyboy/vapormarkdown
leaf markdown tag vapor
Last synced: about 2 months ago
JSON representation
vapor leaf 模版引擎的Markdown标签
- Host: GitHub
- URL: https://github.com/skeyboy/vapormarkdown
- Owner: skeyboy
- Created: 2018-11-02T14:17:50.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-02T14:18:56.000Z (over 7 years ago)
- Last Synced: 2025-01-17T10:30:17.650Z (over 1 year ago)
- Topics: leaf, markdown, tag, vapor
- Language: Swift
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# VaporMarkdown
vapor [leaf](https://github.com/vapor/leaf.git) 模版引擎的Markdown标签
>1 SPM引入
```
.package(url: "https://github.com/skeyboy/VaporMarkdown.git", from: "0.0.1"),
```
>2 注册标签
```
services.register { (Container) -> (LeafTagConfig) in
var tagConfig = LeafTagConfig.default()
tagConfig.use( VaporMarkdown.init(), as: "markdown")
return tagConfig
}
```
>3 使用 markdown.leaf
```
let msg = """
# 我是一个markdown
## 我是一个副标题
> 我是一个引用
"""
#markdown(msg)
```
>4 简单测试用例
```
func testMarkdown(){
let markdown = "#markdown(h1)"
let data = TemplateData.dictionary(["h1":.string("# woshi")])
let result = try! renderer.testRender(markdown, data)
print(result)
XCTAssertEqual("
woshi
\n", result)
}
```