【发布时间】:2015-05-21 21:00:35
【问题描述】:
我很难找到有关如何使用 Spullara Mustache java 实现来实现局部的示例。他们的 github 页面似乎没有任何直接的部分示例。
在 DefaultMustacheFactory 中,我看到了 compilePartial 和 resolvePartialPath 的方法,但我不确定是否应该覆盖它们或什么。
我目前有这个,它在没有部分的情况下效果很好。 TemplateContent 包含原始模板 html,包括 mustache 语法。
public Mustache compileMustacheTemplate(String templateCode, String templateContent){
return new DefaultMustacheFactory().compile(new StringReader(templateContent),templateCode);
}
非常直接。但是如果模板内容里面有 {{>partialName}} 呢?我想我还需要以某种方式指定该模板内容。
我是否需要扩展 DefaultMustacheFactory 或可能的其他类来指定我的部分名称及其内容?
我相信我只是错过了一些东西。
谢谢, 马特
【问题讨论】: