1
我在我的項目中嵌入了模板模板(Kitura https://github.com/IBM-Swift/Kitura,模板引擎Stencil https://github.com/kylef/Stencil#include)。我不明白如何使用標籤{% include "comment.html" %}
。 我的例子,但沒有工作。如何使用標籤{%include example.html%}使用Swift的模板
example.stencil.html
<html>
<head>
hello example
{% include "include.stencil.html" %}
</head>
</html>
include.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)"
}
Error :Error:'include.stencil.html' template not found in ../include.stencil.html
如何使用它,幫我PLZ。 :)