Closed codeconsole closed 1 year ago
GroovyPageParser is configured after initialization which is totally useless.
For instance, in the constructor the method isSitemeshPreprocessingEnabled is run which looks to see if enableSitemeshPreprocessing is set, but the variable isn't set until AFTER initialization!
isSitemeshPreprocessingEnabled
enableSitemeshPreprocessing
GroovyPagesTemplateEngine
String gspSource = IOUtils.toString(inputStream, getGspEncoding()); parser = new GroovyPageParser(name, path, path, decorateGroovyPageSource(new StringBuilder(gspSource)).toString()); if (grailsApplication != null) { Config config = grailsApplication.getConfig(); parser.configure(config); }
GroovyPageParser
public GroovyPageParser(String name, String uri, String filename, String gspSource, String expressionCodecName) throws IOException { this.expressionCodecDirectiveValue = expressionCodecName; if (expressionCodecDirectiveValue == null) { expressionCodecDirectiveValue = OutputEncodingSettings.getDefaultValue(OutputEncodingSettings.EXPRESSION_CODEC_NAME); } Map<String, String> directives = parseDirectives(gspSource); if (isSitemeshPreprocessingEnabled(directives.get(SITEMESH_PREPROCESS_DIRECTIVE))) { // GSP preprocessing for direct sitemesh integration: replace head -> g:captureHead, title -> g:captureTitle, meta -> g:captureMeta, body -> g:captureBody gspSource = sitemeshPreprocessor.addGspSitemeshCapturing(gspSource); sitemeshPreprocessMode=true; } scan = new GroovyPageScanner(gspSource, uri); pageName = uri; environment = Environment.getCurrent(); makeName(name); makeSourceName(filename); }
Fix: Put configuration in the constructor.
GroovyPageParser is configured after initialization which is totally useless.
For instance, in the constructor the method
isSitemeshPreprocessingEnabled
is run which looks to see ifenableSitemeshPreprocessing
is set, but the variable isn't set until AFTER initialization!GroovyPagesTemplateEngine
GroovyPageParser
Fix: Put configuration in the constructor.