Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix for GRAILS-9059

  • Loading branch information...
commit b4bb4f614a25837c2731895c8074526a39af5348 1 parent 15b2fad
@lhotari lhotari authored
View
23 grails-plugin-gsp/src/main/groovy/org/codehaus/groovy/grails/plugins/web/taglib/RenderTagLib.groovy
@@ -240,13 +240,24 @@ class RenderTagLib implements RequestConstants {
def invokeBody = true
for (i in 0..<names.size()) {
- String propertyValue = htmlPage.getProperty(names[i])
+ def propertyValue = null
+ if (htmlPage instanceof GSPSitemeshPage) {
+ // check if there is an component content buffer
+ propertyValue = htmlPage.getContentBuffer(names[i])
+ }
+
+ if (!propertyValue) {
+ propertyValue = htmlPage.getProperty(names[i])
+ }
+
if (propertyValue) {
- if (attrs.equals instanceof List) {
- invokeBody = attrs.equals[i] == propertyValue
- }
- else if (attrs.equals instanceof String) {
- invokeBody = attrs.equals == propertyValue
+ if(attrs.containsKey('equals')) {
+ if (attrs.equals instanceof List) {
+ invokeBody = attrs.equals[i] == propertyValue
+ }
+ else {
+ invokeBody = attrs.equals == propertyValue
+ }
}
}
else {
View
26 grails-test-suite-web/src/test/groovy/org/codehaus/groovy/grails/web/taglib/RenderTagLibTests.groovy
@@ -18,11 +18,14 @@ package org.codehaus.groovy.grails.web.taglib
import grails.util.GrailsUtil
import org.codehaus.groovy.grails.support.MockStringResourceLoader
+import org.codehaus.groovy.grails.web.pages.FastStringWriter;
import org.codehaus.groovy.grails.web.pages.GroovyPageBinding
import org.codehaus.groovy.grails.web.servlet.GrailsApplicationAttributes
import org.codehaus.groovy.grails.web.sitemesh.FactoryHolder
+import org.codehaus.groovy.grails.web.sitemesh.GSPSitemeshPage;
import org.codehaus.groovy.grails.web.sitemesh.GrailsLayoutDecoratorMapper
import org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException
+import org.codehaus.groovy.grails.web.util.StreamCharBuffer;
import org.springframework.web.servlet.support.RequestContextUtils as RCU
import com.opensymphony.module.sitemesh.RequestConstants
@@ -58,6 +61,29 @@ class RenderTagLibTests extends AbstractGrailsTagTests {
template = '<g:pageProperty name="foo.bar" writeEntireProperty="true" />'
assertOutputEquals " bar=\"good\"", template
}
+
+
+ void testIfPageProperty() {
+ def template = '<g:ifPageProperty name="foo.bar">Hello</g:ifPageProperty>'
+
+ TokenizedHTMLPage page = new TokenizedHTMLPage([] as char[], new CharArray(0), new CharArray(0))
+ request[RequestConstants.PAGE] = page
+
+ page.addProperty("foo.bar", "true")
+
+ assertOutputEquals "Hello", template
+
+ template = '<g:ifPageProperty name="page.contentbuffer">Hello 2</g:ifPageProperty>'
+
+ GSPSitemeshPage smpage = new GSPSitemeshPage()
+ request[RequestConstants.PAGE] = smpage
+
+ FastStringWriter sw=new FastStringWriter()
+ sw.write("true")
+ smpage.setContentBuffer("contentbuffer", sw.getBuffer())
+
+ assertOutputEquals "Hello 2", template
+ }
void testTemplateNamespace() {
def resourceLoader = new MockStringResourceLoader()
Please sign in to comment.
Something went wrong with that request. Please try again.