java - spullara mustache java 偏音

标签 java mustache partials

我无法找到有关如何使用 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/

相关文章:

Jquery clone() 似乎不适用于 Mustaches

javascript - Backbone JS单页应用文件上传?

jquery - Rails 4 使用 ajax、jquery、:remote => true, 和 respond_to 渲染部分

handlebars.js - Handlebars 部分文件不清楚

javascript - Angular 部分标题 View

.ts 文件中的 Java BufferedImages

linux - Java Swing - 当 JFrame 最大化时上下文菜单上的鼠标指针 "shifted"

javascript - mustache 空值

java - 使用 JDBI3 保留枚举字段的简洁方法?

java - antlr4 - 获取规则上下文的左右兄弟