Malline 是一个简单而强大的 Swift 模板语言。 它提供了类似于 Handlebars & Mustache 的语法。 如果你熟悉这些,你会很快适应 Malline。
There are {{ articles.count }} articles.
<ul>
{% for article in articles %}
<li>{{ article.title }} by {{ article.author }}</li>
{% endfor %}
</ul>
import Malline
struct Article {
let title: String
let author: String
}
let context = [
"articles": [
Article(title: "Limitations and Inevitable Demise of Blockchains", author: "Tauno Lehtinen"),
Article(title: "Distributed Social Networks in Swift", author: "Tauno Lehtinen"),
]
]
let environment = Environment(loader: FileSystemLoader(paths: ["templates/"]))
let rendered = try environment.renderTemplate(name: context)
print(rendered)
Malline 模板作者编写 Malline 模板的资源
帮助你将 Malline 集成到 Swift 项目中的资源
Malline 采用 MIT 许可证。 更多信息请查看 LICENSE。