【问题标题】:How to implement layout template with spring boot and mustache如何使用 Spring Boot 和 Mustache 实现布局模板
【发布时间】:2015-12-24 08:53:19
【问题描述】:

我有一个使用 Mustache 模板引擎的 Spring Initlializer 创建的 Sprint Boot Web Maven 项目。

到目前为止,它工作正常,我可以做一些基本的事情,但我想设置一个布局(模板),其中包括 html 的主体,例如<html>...</html> 而我的视图模板将仅包含页面内容,例如<h1>Hello World</h1>

我可以让部分工作,所以我可以做{{>header}}<h1>Hello World</h1>{{>footer}}

我想做的是:

index.html

{{>header}}{{>content}}{{>footer}}

home.html

<h1>Hello World</h1>

我找不到任何教程或文档如何做到这一点。

【问题讨论】:

    标签: spring-boot mustache


    【解决方案1】:

    如果有帮助,我在这里找到了一些参考文档:

    https://spring.io/blog/2016/11/21/the-joy-of-mustache-server-side-templates-for-the-jvm

    请参阅自然模板部分。

    {{!
    <!doctype html>
    <html lang="en">
    <body>
    }}
    {{>header}}
       <h1>Demo</h1>
       <div>Hello World</div>
    {{>footer}}
    {{!
    </body>
    </html>
    }}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-09-09
      • 1970-01-01
      • 1970-01-01
      • 2014-05-11
      • 1970-01-01
      • 2015-12-21
      • 2019-10-08
      相关资源
      最近更新 更多