g:layoutBody behavior in Grails 3 is different than Grails 2

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

g:layoutBody behavior in Grails 3 is different than Grails 2

Scott Ingram
I have a componentized single-page webapp that relies very heavily on g:applyLayout, g:include, and g:layoutBody.  I have a workbench.gsp that aggregates numerous smaller widgetFoo.gsp files.  They are structured in such a way that each widget defines its individual JS and CSS dependencies and is fully functional whether it is rendered in isolation all by itself or when aggregated together with other widgets by workbench.gsp.

I am upgrading from grails 2.2.1 grails 3.1 and have encountered a problem.   I can find no explanation in any documentation, stack overflow, or forums.

The following code behaves very differently depending on which version of Grails I use.

workbench.gsp
<html>
<head>
   
<meta name="layout" content="workbench" />
   
<title>Workbench TEST GSP</title>
</head>

<body>
   
<h1>Workbench</h1>

   
<div>
       
<g:applyLayout name="body-only">
           
<g:include
                   
controller="workbench"
                   
action="w1"
           
/>
       
</g:applyLayout>
   
</div>
</body>
</html>


layouts/workbench.gsp
<html>
<head>
 
<title><g:layoutTitle default="Heavy Meta"/></title>
   
<g:layoutHead/>

</head>

<body>
   
<g:layoutBody/>
</body>

</html>

layouts/body-only.gsp
<g:layoutBody/>

widget1.gsp
<html>
    <head>
        <title>W1 - Grails 2 does not render this during layoutBody but Grails 3 does</title>
    </head>
    <body>
        <h1>I am widget #1 - Hear me Roar!</h1>
    </body>
</html>


Grails 2 produces this:
<html>
<head>
 
<title>Workbench TEST GSP</title>
   
<meta name="layout" content="workbench">
</head>

<body>
    
<h1>Workbench</h1>

   
<div>
       
<h1>I am widget #1 - Hear me Roar!</h1>
    
</div>

</body>
</html>



Grails 3 produces this:
<html>
<head>

   
<meta name="layout" content="workbench">
   
<title>Workbench TEST GSP</title>
</head>

<body>
   
<h1>Workbench</h1>

    
<div>
        
<title>W1 - Grails 2 does not render this during layoutBody but Grails 3 does</title>
        
<h1>I am widget #1 - Hear me Roar!</h1>
    
</div>

</body>
</html>


It may seem minor in this trivial example, but, when I put more than one widget on the page, it gets worse.  And when their head elements include  <asset:javascript src="widget-ONE-manifest.js"/> and <asset:javascript src="widget-TWO-manifest.js"/> where ONE and TWO have overlapping dependencies, all hell breaks loose.  So, I thought I would present my problem in what seems to be its most fundamental form first and work forward from there.

Any insights? 
    


--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/272bacf6-49de-405a-b587-6fb13054df0b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.