Skip to content

Commit

Permalink
Fix null pointer issue when attrs are not supplied to withTag
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Potter authored and Jeff Scott Brown committed Aug 20, 2013
1 parent 3650f39 commit 5ef47e2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ class ApplicationTagLib implements ApplicationContextAware, InitializingBean, Gr
Closure withTag = { attrs, body ->
def writer = out
writer << "<${attrs.name}"
attrs.attrs.each { k,v ->
attrs.attrs?.each { k,v ->
if (!v) return
if (v instanceof Closure) {
writer << " $k=\""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,4 +423,12 @@ class ApplicationTagLibTests extends AbstractGrailsTagTests {
def template = '<g:createLink controller="foo" action="bar" id="|prop:8888" />'
assertOutputEquals '/foo/bar/%7Cprop%3A8888', template
}

void testWithTagWithNameAndAttrs() {
def template = '<g:withTag name="div" attrs="[class: 'foo']>body</g:withTag>'
assertOutputEquals '<div class="foo">body</div>', template

template = '<g:withTag name="div">body</g:withTag>'
assertOutputEquals '<div>body</div>', template
}
}

0 comments on commit 5ef47e2

Please sign in to comment.