我很难找到如何使用Spullara Mustache java实现实现partials的示例.他们的github页面似乎没有任何直接的部分示例.
在DefaultMustacheFactory中,我看到了compilePartial和resolvePartialPath的方法,但我不确定是否应该覆盖它们或者是什么.
我目前有这个,它没有偏见很好.TemplateContent包含原始模板html,包括胡子语法.
public Mustache compileMustacheTemplate(String templateCode, String templateContent){
return new DefaultMustacheFactory().compile(new StringReader(templateContent),templateCode);
}
Run Code Online (Sandbox Code Playgroud)
挺直的.但是如果模板内容里面有{{> partialName}}怎么办?我想我还需要以某种方式指定模板内容.
我是否需要扩展DefaultMustacheFactory或可能是另一个类来指定我的部分名称及其内容?
我相信我只是缺少一些东西.
谢谢,马特