我无法找到有关如何使用 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 或其他可能的类来指定我的局部名称及其内容?
我相信我只是错过了一些东西。
谢谢, 马特
最佳答案
假设您的模板文件存储在文件夹“src/main/resources/org/example/web/”中,并且您有一个模板“page.html”文件引用另外两个模板文件“header.html”和“footer” .html'。您的模板文件“page.html”应如下所示:
{{> src/main/resources/org/example/web/header.html}}
... some content ...
{{> src/main/resources/org/example/web/footer.html}}
关于java - spullara mustache java 偏音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29132868/