Permalink
Browse files

Fix for GRAILS-9059

  • Loading branch information...
1 parent 15b2fad commit b4bb4f614a25837c2731895c8074526a39af5348 @lhotari lhotari committed Apr 30, 2012
@@ -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 {
@@ -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()

0 comments on commit b4bb4f6

Please sign in to comment.