我在我的项目中嵌入了模板模板(Kitura https://github.com/IBM-Swift/Kitura,模板引擎模板https://github.com/kylef/Stencil#include)。我不明白如何使用标签{% include "comment.html" %}
。我的例子,但不起作用。
example.stencil.html
<html>
<head>
hello example
{% include "include.stencil.html" %}
</head>
</html>
包括.stencil.html
<b>I'm here</b>
代码迅速
import Stencil
let pathTemp=Path("include.stencil.html")
let context = Context(dictionary: ["loader": TemplateLoader(paths: [pathTemp])])
do {
let template = try Template(named: fileName)
let rendered = try template.render(context)
return rendered
}catch
{
return "Error:\(error)"
}
错误:错误:在 ../include.stencil.html 中找不到“include.stencil.html”模板
如何使用它,请帮助我。:)