codeconsole commented on code in PR #15585:
URL: https://github.com/apache/grails-core/pull/15585#discussion_r3139952169


##########
grails-gsp/grails-sitemesh3/src/main/groovy/org/grails/plugins/web/taglib/RenderSitemeshTagLib.groovy:
##########
@@ -148,40 +163,44 @@ class RenderSitemeshTagLib implements TagLibrary {
         }
     }
 
+    // layoutTitle/layoutHead/layoutBody inline-expand at tag-render time.
+    // This avoids emitting <sitemesh:write> placeholders that would otherwise
+    // require a second HTML parse of the layout output to expand. The
+    // property is pulled directly from the Content being merged (set on the
+    // request under WebAppContext.CONTENT_KEY by WebAppContext.decorate).
     Closure layoutTitle = { attrs ->
-        out << """<sitemesh:write property="title">${attrs.default ?: 
''}</sitemesh:write>""".toString()
+        ContentProperty titleProp = getContentProperty('title')
+        String defaultValue = attrs.default?.toString() ?: ''
+        if (titleProp?.hasValue()) {
+            titleProp.writeValueTo(out)
+        } else if (defaultValue) {
+            out << defaultValue
+        }
     }
 
     Closure layoutHead = { attrs, body ->
-        StringBuilder tag = new StringBuilder('<sitemesh:write 
property="head"')
-        String bodyContent = body()
-        if (bodyContent) {
-            tag.append('>')
-            tag.append(bodyContent)
-            tag.append('</sitemesh:write>')
-        } else {
-            tag.append('/>')
+        ContentProperty headProp = getContentProperty('head')
+        if (headProp?.hasValue()) {
+            headProp.writeValueTo(out)
+        } else if (body) {
+            out << body()
         }
-        out << tag.toString()
     }
 
     Closure layoutBody = { attrs, body ->
-        StringBuilder tag = new StringBuilder('<sitemesh:write 
property="body"')
-        String bodyContent = body()
-        if (bodyContent) {
-            tag.append('>')
-            tag.append(bodyContent)
-            tag.append('</sitemesh:write>')
-        } else {
-            tag.append('/>')
+        ContentProperty bodyProp = getContentProperty('body')
+        if (bodyProp?.hasValue()) {
+            bodyProp.writeValueTo(out)
+        } else if (body) {
+            out << body()
         }
-        out << tag.toString()
     }
 
     Closure content = { attrs, body ->
-        StringBuilder tag = new StringBuilder("""<content 
tag="${attrs.tag}">""")
-        tag.append(body())
-        tag.append('</content>')
-        out << tag.toString()
+        out << '<content tag="'
+        out << attrs.tag

Review Comment:
   Fixed — added @Autowired CodecLookup and HTML-encoded via 
codecLookup.lookupEncoder('HTML'), matching captureTagContent.



-- 
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]

Reply via email to