java - Spring MVC, Tiles2, ThymeLeaf and Natural Templating -
how use thymeleaf natural templating while using tiles2 template engine. have 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 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"/> ... , many others </head> <body> <div class="top-header" tiles:include="header">header include</div> <div class="container-main" tiles:include="content">content include</div> <div tiles:include="footer">footer include</div> </body>
and simple content.html template
<div id="main" class="panel panel-main"> <div id="contents" class="panel-body"> bla bla bla </div> </div>
the problem have that: if tried check content.html locally not should because had not defined <html>
, <head>
having css , js definitions.
if added <html><head>
tags on runtime had many html definitions (from header/content/footer templates) on resulting page!
a perfect solution me that: define content.html <html><head>
tags taking full advantage of natural templating , syntax checking, , somehow include file without these tags (only body or div) possible?
you can use
<!-- /* -->
and
<!--*/-->.
every tags inside these comments tags ignore during runtime (they won't show in actual page).
<!--/*--> <html> <head> <title>test</title> </head> <body> <!--*/--> <div>...</div> <!--/*--> <body> </html> <!--*/-->
Comments
Post a Comment