monetschemist commented on issue #14204:
URL: https://github.com/apache/grails-core/issues/14204#issuecomment-3211399894
Not sure this is the place to offer this, but here is a slightly different
way of exploiting the Asset Pipeline that I regularly use.
For example, when I want to include some separate JavaScript libraries and
code at the end of my views, for example including some chart drawing stuff in
GSPs where it makes sense, I do something like this
**layouts/main.gsp**
```
<!doctype html>
<html lang="es" class="no-js">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<title><g:layoutTitle default="MyApp"/></title>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<asset:link rel="icon" href="favicon.ico" type="image/x-ico"/>
<asset:stylesheet src="application.css"/>
<g:layoutHead/>
</head>
<body>
<!-- the usual common navigation boilerplate -->
<g:layoutBody/>
<div id="spinner" class="spinner" style="display:none;">
<g:message code="spinner.alt" default="Loading…"/>
</div>
<asset:javascript src="application.js"/>
<g:ifPageProperty name="page.additionalJS">
<g:pageProperty name="page.additionalJS"/>
</g:ifPageProperty>
</body>
</html>
```
**home/index.gsp**
```
<!doctype html>
<html>
<head>
<meta name="layout" content="main"/>
<title>My Application</title>
</head>
<body>
<div id="content" class="container-fluid" role="main">
<!-- the working part of index.gsp and its navigation buttons -->
</div>
<content tag="additionalJS">
<script
src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.7.1/chart.min.js"></script>
<script
src="https://cdn.jsdelivr.net/npm/chartjs-adapter-date-fns/dist/chartjs-adapter-date-fns.bundle.min.js"></script>
<script>
/* my JavaScript code specific to the chart that makes sense for the home
page index.gsp */
</script>
</content>
</body>
</html>
```
This lets me reuse the same `main.gsp` for different pages with different
scripting requirements.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]