I'm still kind of new to Thymeleaf and SpringBoot.
I have been trying to inject a block with all the javascript mappings into a page - dashboardAdmin.html using thymeleaf fragments.
I have been able to inject fragments with enveloped with a block correctly using the conventional fragments however since i have to inject multiple script tags that are not within any tag in the html template, I wasn't able to use the conventional method.
I found a similar question here and have follow the specific solution provided but still have not succeeded and I have added the dependency. Perhaps there is some sort of syntax error that I do not know about. Since I couldn't find much reference on this, can anyone kindly advice me on this?
This is the fragment.html which contains all the templates to be inserted into other pages
<body>
<th:block layout:fragment="script">
<script th:src="@{/vendor/login_v14/vendor/jquery/jquery-3.2.1.min.js}"></script>
<!-- Bootstrap 4 -->
<script th:src="@{/vendor/bootstrap/js/bootstrap.bundle.min.js}"></script>
<!-- jsGrid -->
<script th:src="@{/vendor/jsgrid/demos/db.js}"></script>
<script th:src="@{/vendor/jsgrid/jsgrid.min.js}"></script>
<!-- AdminLTE App -->
<script th:src="@{/js/main.js}"></script>
</th:block>
</body>
While this is the page template that I am injecting the block to - dashboardAdmin.html
<!DOCTYPE html>
<html lang="fr" xmlns:th="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/html"
xmlns:layout="http://www.w3.org/1999/xhtml"
layout:decorate="~{fragments/fragments}">
<head th:replace="fragments/fragments :: head">
</head>
<body class="hold-transition sidebar-mini">
<!--js scripts-->
<th:block layout:fragment="script">
</th:block>
</body>
If someone could tell me what I'm doing wrong here, it will be much appreciated :D !