Mat*_*ley 5 java partials mustache
我很难找到如何使用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或可能是另一个类来指定我的部分名称及其内容?
我相信我只是缺少一些东西.
谢谢,马特
假设您的模板文件存储在文件夹“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}}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1362 次 |
| 最近记录: |