Grails

ApplicationTagLib.img() collides with 'img' in Groovy's MarkupBuilder within a TagLib

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Won't Fix
  • Affects Version/s: 2.0 final
  • Fix Version/s: None
  • Component/s: TagLib
  • Labels:
    None

Description

When using Groovy's MarkupBuilder in a TagLib to render an HTML image the wrong method (namely ApplicationTagLib.img()) is called:

def myTag = { attrs, body ->
new MarkupBuilder(out).div { img(src: 'image.png', alt: 'Description') }
}

A possible workaround is to call 'img' explicitly on 'delegate':

def myTag = { attrs, body ->
new MarkupBuilder(out).div { delegate.img(src: 'image.png', alt: 'Description') }
}

Activity

Hide
Graeme Rocher added a comment -

The workaround is the correct way to implement this, another alternative is to use g.img.

There is no way to fix this without the user applying some manual scoping, closing...

Show
Graeme Rocher added a comment - The workaround is the correct way to implement this, another alternative is to use g.img. There is no way to fix this without the user applying some manual scoping, closing...

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: