Skip to content

Commit

Permalink
Fix for GRAILS-9059
Browse files Browse the repository at this point in the history
  • Loading branch information
lhotari committed Apr 30, 2012
1 parent f294688 commit 988e940
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -111,6 +114,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()
Expand Down

0 comments on commit 988e940

Please sign in to comment.