Reputation: 3166
How to effectively use ThymeLeaf natural templating while using Tiles2 as a template engine. I have a simple tiles definition:
<tiles-definitions>
<definition name="/**;layout:*" template="templates/{2}_layout">
<put-attribute name="header" value="templates/header"/>
<put-attribute name="content" value="/{1}"/>
<put-attribute name="footer" value="templates/footer"/>
</definition>
...
</tiles-definitions>
and my layout
<html lang="pl" xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.springframework.org/security/tags"
xmlns:tiles="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" type="text/css" th:href="@{~/css/bootstrap.min.css}" href="../../../css/bootstrap.min.css"/>
... and many others
</head>
<body>
<div class="top-header" tiles:include="header">Header to include</div>
<div class="container-main" tiles:include="content">Content to include</div>
<div tiles:include="footer">Footer to include</div>
</body>
and a simple content.html template
<div id="main" class="panel panel-main">
<div id="contents" class="panel-body">
bla bla bla
</div>
</div>
The problem I have is that:
If I tried to check the content.html locally then it would not look like it should because I had not defined <html>
and <head>
having CSS and JS definitions.
If I added <html><head>
tags then on runtime I had many html definitions (from header/content/footer templates) on the resulting page!
A perfect solution for me could be that: I would like to define content.html with <html><head>
tags taking full advantage of natural templating and syntax checking, and then somehow include this file but without these tags (only body or div) Is it possible?
Upvotes: 0
Views: 446
Reputation: 1552
You can use
<!-- /* -->
and
<!--*/-->.
Every tags inside these comments tags are ignore during runtime (They won't show up in the actual page).
<!--/*-->
<html>
<head>
<title>Test</title>
</head>
<body>
<!--*/-->
<div>...</div>
<!--/*-->
<body>
</html>
<!--*/-->
Upvotes: 0