codeconsole commented on code in PR #15585:
URL: https://github.com/apache/grails-core/pull/15585#discussion_r3139955381
##########
grails-gsp/grails-sitemesh3/src/main/groovy/org/grails/plugins/sitemesh3/Sitemesh3GrailsPlugin.groovy:
##########
@@ -48,55 +55,73 @@ class Sitemesh3GrailsPlugin extends Plugin {
def loadBefore = ['groovyPages']
def providedArtefacts = [
- RenderSitemeshTagLib,
+ RenderSitemeshTagLib,
+ Sitemesh3LayoutTagLib,
]
static PropertySource getDefaultPropertySource(ConfigurableEnvironment
configurableEnvironment, String defaultLayout) {
-
Map props = [
- 'grails.gsp.view.layoutViewResolver': 'false',
'sitemesh.decorator.metaTag': 'layout',
'sitemesh.decorator.attribute': WebUtils.LAYOUT_ATTRIBUTE,
'sitemesh.decorator.prefix': '/layouts/',
- 'sitemesh.filter.order': GrailsFilters.SITEMESH_FILTER.order,
- 'sitemesh.decorator.tagRuleBundles':
['org.sitemesh.content.tagrules.html.Sm2TagRuleBundle']
]
if (defaultLayout) {
props['sitemesh.decorator.default'] = defaultLayout
}
- // if property already exists, don't override
props.clone().each {
if (configurableEnvironment.getProperty(it.key)) {
props.remove(it.key)
}
}
- return new MapPropertySource('defaultSitemesh3Properties', props)
+ new MapPropertySource('defaultSitemesh3Properties', props)
}
Closure doWithSpring() {
{ ->
ConfigurableEnvironment configurableEnvironment =
grailsApplication.mainContext.environment as ConfigurableEnvironment
def propertySources = configurableEnvironment.getPropertySources()
- // https://grails.apache.org/docs/latest/guide/single.html#layouts
- // Default view should be application, but it is inefficient to
add a rule for a page that may not exist.
String defaultLayout =
grailsApplication.getConfig().getProperty('grails.sitemesh.default.layout')
propertySources.addFirst(getDefaultPropertySource(configurableEnvironment,
defaultLayout))
- propertySources.addFirst(new
MapPropertySource('requiredSitemesh3Properties', [
-
(GroovyPageParser.CONFIG_PROPERTY_GSP_GRAILS_LAYOUT_PREPROCESS): 'false'
- ]))
(grailsApplication as DefaultGrailsApplication).config = new
PropertySourcesConfig(propertySources)
- grailsLayoutHandlerMapping(GrailsLayoutHandlerMapping)
+ Config config = grailsApplication.getConfig()
+ boolean developmentMode =
Metadata.getCurrent().isDevelopmentEnvironmentAvailable()
+ Environment env = Environment.current
+ boolean enableReload = env.isReloadEnabled() ||
+ config.getProperty('grails.gsp.enable.reload', Boolean,
false) ||
+ (developmentMode && env == Environment.DEVELOPMENT)
+ String resolvedDefaultLayout =
config.getProperty('grails.sitemesh.default.layout') ?:
+ config.getProperty('sitemesh.decorator.default')
Review Comment:
Fixed — simplified to String resolvedDefaultLayout = defaultLayout.
--
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]