3
votes

I have a Sprint Boot Web Maven project created from Spring Initlializer with Mustache templating engine.

So far, its working and I can do the basic things but I want to set a layout (template) that will include the main body of html e.g. <html>...</html> whilst my view template will only include the page content e.g. <h1>Hello World</h1>

I can get partials to work so I could do {{>header}}<h1>Hello World</h1>{{>footer}}

What I want to be able to do is:

index.html

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

home.html

<h1>Hello World</h1>

I can't find any tutorial or documentation how do this.

1

1 Answers

0
votes

If it helps, I found some reference documentation here:

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

See the section on Natural Templates.

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