0

Stencil のドキュメントの手順に従って、簡単なカスタム タグを登録しました。

let ns = Namespace()

ns.registerSimpleTag("contact") { context in
  return "<a href=\"/contact\">contact us</a>"
}

しかし、実際のオブジェクトではなく辞書のみを取るためrender、に名前空間を渡す方法がわかりません。response.renderContext

私は何が欠けていますか?自分で名前空間を作成する代わりに、使用すべき既存の名前空間はありますか?

4

1 に答える 1

1

https://github.com/IBM-Swift/Kitura-StencilTemplateEngineをフォークして、 KituraStencilTemplateEngine.swiftを変更できます。

StencilTemplateEngine.render()でns名前空間を定義し、リターン コード行を次のように変更します。

return try template.render(Context(dictionary: context), namespace: ns)

次に、フォークにタグを追加し、フォークをPackage.swiftの依存関係として使用します。

于 2016-11-14T19:39:58.053 に答える