Reputation: 86737
In the following example, I only want to create a simple main.html
layout, and home.html
, about.html
.
The subpages should only contain their own content body, not header or footer inclusions.
This is what I have so far, but how could I now dynamically replace the container
content with the page that was clicked?
<html>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="/home">Home</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="/about">About</a></li>
</ul>
</div>
</div>
</div>
<div class="container">
<p>This should always get replaced when a link is clicked</p>
<!--<div th:replace="fragments/pagename :: pagename">-->
</div>
</body>
</html>
If I'd only had one page, I could replace the content with <div th:replace="fragments/about :: about">
, but how could I do this dynamically?
Upvotes: 2
Views: 2275
Reputation: 86737
The deprecation message came from <html layout:decorate="layout">
. Rewriting it to <html layout:decorate="~{layout}">
fixed the message.
Anyways, thymeleaf
seem to lack this important feature, thus using the thymeleaf-layout-dialect
layout dialect is the only way to go.
Upvotes: 1