I have a weird issue where some of my html files are not being included when I use replace or include. What would cause this?
header.html
<header id="header" xmlns:th="http://www.thymeleaf.org">
<div th:replace="/blocks/topbar :: topbar"></div>
</header>
topbar.html
<div class="top-bar">
<div class="container">
<div class="row">
<div class="col-sm-6 col-xs-4">
<div class="top-number"><p><i class="fa fa-phone-square"></i> +0123 456 70 90</p></div>
</div>
<div class="col-sm-6 col-xs-8">
<div class="social">
<ul class="social-share">
<li><a href="#"><i class="fa fa-facebook"></i></a></li>
</ul>
</div>
</div>
</div>
</div><!--/.container-->
</div><!--/.top-bar-->
Error:
org.thymeleaf.exceptions.TemplateInputException: Error resolving fragment: "~{'/blocks/topbar' :: topbar}": template or fragment could not be resolved (template: "blocks/header" - line 3, col 10)
There is no th:fragment="topbar"
in your topbar.html
.
An additional <div>
may solve your problem.
<div th:fragment="topbar">
<!--fragment div start-->
<div class="top-bar">
<div class="container">
<div class="row">
<div class="col-sm-6 col-xs-4">
<div class="top-number">
<p><i class="fa fa-phone-square"></i> +0123 456 70 90</p>
</div>
</div>
<div class="col-sm-6 col-xs-8">
<div class="social">
<ul class="social-share">
<li><a href="#"><i class="fa fa-facebook"></i></a>
</li>
</ul>
</div>
</div>
</div>
</div>
<!--/.container-->
</div>
<!--/.top-bar-->
</div>
<!--fragment div end-->
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With