Skip to content
This repository was archived by the owner on Mar 10, 2025. It is now read-only.

Commit 7683cb3

Browse files
committed
Merge branch '6.2.x' into 7.0.x
2 parents 44889ea + 46005c3 commit 7683cb3

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

.github/workflows/gradle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,4 @@ jobs:
8585
BRANCH: gh-pages
8686
FOLDER: build/docs
8787
COMMIT_EMAIL: [email protected]
88-
COMMIT_NAME: grails-build
88+
COMMIT_NAME: grails-build

grails-web-gsp-taglib/src/main/groovy/org/grails/plugins/web/taglib/RenderTagLib.groovy

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class RenderTagLib implements TagLibrary {
4747
* &lt;g:render template="atemplate" bean="${user}" /&gt;<br/>
4848
*
4949
* @attr template REQUIRED The name of the template to apply
50+
* @attr optional if true, this tag will be ignored when the template does not exist.
5051
* @attr contextPath the context path to use (relative to the application context path). Defaults to "" or path to the plugin for a plugin view or template.
5152
* @attr bean The bean to apply the template against
5253
* @attr model The model to apply the template against as a java.util.Map
@@ -75,7 +76,7 @@ class RenderTagLib implements TagLibrary {
7576
def currentOut = out
7677
int statusCode = request.getAttribute('jakarta.servlet.error.status_code') as int
7778
currentOut << """<h1>Error ${prettyPrintStatus(statusCode)}</h1>
78-
<dl class="error-details">
79+
<dl class="${attrs['detailsClass'] ?: 'error-details'}">
7980
<dt>URI</dt><dd>${htmlEncoder.encode(WebUtils.getForwardURI(request) ?: request.getAttribute('jakarta.servlet.error.request_uri'))}</dd>
8081
"""
8182

@@ -87,12 +88,12 @@ class RenderTagLib implements TagLibrary {
8788
}
8889
currentOut << "</dl>"
8990

90-
currentOut << errorsViewStackTracePrinter.prettyPrintCodeSnippet(exception)
91+
currentOut << errorsViewStackTracePrinter.prettyPrintCodeSnippet(exception, attrs)
9192

92-
def trace = errorsViewStackTracePrinter.prettyPrint(exception.cause ?: exception)
93+
def trace = errorsViewStackTracePrinter.prettyPrint(exception.cause ?: exception, attrs)
9394
if (StringUtils.hasText(trace.trim())) {
9495
currentOut << "<h2>Trace</h2>"
95-
currentOut << '<pre class="stack">'
96+
currentOut << """<pre class="${attrs['stackClass'] ?: 'stack'}">"""
9697
currentOut << htmlEncoder.encode(trace)
9798
currentOut << '</pre>'
9899
}

grails-web-gsp/src/main/groovy/org/grails/web/gsp/GroovyPagesTemplateRenderer.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ public void render(GrailsWebRequest webRequest, TemplateVariableBinding pageScop
114114
final Object controller = webRequest.getAttribute(GrailsApplicationAttributes.CONTROLLER, GrailsWebRequest.SCOPE_REQUEST);
115115
Template t = findAndCacheTemplate(controller, pageScope, templateName, contextPath, pluginName, uri);
116116
if (t == null) {
117+
if (getBooleanValue(attrs, "optional")) {
118+
return; // allow missing templates if optional == "true"
119+
}
117120
throw new GrailsTagException("Template not found for name [" + templateName + "] and path [" + uri + "]");
118121
}
119122

@@ -288,6 +291,12 @@ private String getStringValue(Map<String, Object> attrs, String key) {
288291
return String.valueOf(val);
289292
}
290293

294+
private boolean getBooleanValue(Map<String, Object> attrs, String key) {
295+
String val = getStringValue(attrs, key);
296+
if (val.isBlank()) return false;
297+
return Boolean.parseBoolean(val);
298+
}
299+
291300
public void setGroovyPageLocator(GrailsConventionGroovyPageLocator locator) {
292301
groovyPageLocator = locator;
293302
}

0 commit comments

Comments
 (0)