Skip to content

Commit

Permalink
Merge pull request #498 from grails/6.2.x
Browse files Browse the repository at this point in the history
Merge 6.2.x
  • Loading branch information
codeconsole authored Sep 25, 2024
2 parents 44889ea + d2ffb2b commit 7ad9856
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ jobs:
BRANCH: gh-pages
FOLDER: build/docs
COMMIT_EMAIL: [email protected]
COMMIT_NAME: grails-build
COMMIT_NAME: grails-build
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class RenderTagLib implements TagLibrary {
* &lt;g:render template="atemplate" bean="${user}" /&gt;<br/>
*
* @attr template REQUIRED The name of the template to apply
* @attr optional if true, this tag will be ignored when the template does not exist.
* @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.
* @attr bean The bean to apply the template against
* @attr model The model to apply the template against as a java.util.Map
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ public void render(GrailsWebRequest webRequest, TemplateVariableBinding pageScop
final Object controller = webRequest.getAttribute(GrailsApplicationAttributes.CONTROLLER, GrailsWebRequest.SCOPE_REQUEST);
Template t = findAndCacheTemplate(controller, pageScope, templateName, contextPath, pluginName, uri);
if (t == null) {
if (getBooleanValue(attrs, "optional")) {
return; // allow missing templates if optional == "true"
}
throw new GrailsTagException("Template not found for name [" + templateName + "] and path [" + uri + "]");
}

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

private boolean getBooleanValue(Map<String, Object> attrs, String key) {
String val = getStringValue(attrs, key);
if (val.isBlank()) return false;
return Boolean.parseBoolean(val);
}

public void setGroovyPageLocator(GrailsConventionGroovyPageLocator locator) {
groovyPageLocator = locator;
}
Expand Down

0 comments on commit 7ad9856

Please sign in to comment.