Grails

Error in taglib example

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.0-RC3
  • Fix Version/s: 1.2 final
  • Component/s: Documentation
  • Labels:
    None
  • Environment:
    Grails 1.0 RC3
  • Patch Submitted:
    Yes

Description

In chapter 6.3 of the Reference Documentation is a wrong taglib example:

class SimpleTagLib {
def emoticon = { attrs, body -> out << body() << attrs.happy == 'true' ? " :-)" : " :-(" }
}

The correct code would be:

class SimpleTagLib {
def emoticon = { attrs, body -> ut << body() << (attrs.happy? ' :-)' : ' :-(') }
}

I've replaced the GStrings with Strings due to the better performance

Activity

Hide
Christian Helmbold added a comment -

Sorry, there is copy&paste error in my code.

class SimpleTagLib {
def emoticon = { attrs, body -> out << body() << (attrs.happy? ' :-)' : ' :-(') }
}

The 'o' of 'out' was missing.

Amendmend to avoid misunderstandings: The change from GString to String has nothing to do with the error in the example code.

Show
Christian Helmbold added a comment - Sorry, there is copy&paste error in my code. class SimpleTagLib { def emoticon = { attrs, body -> out << body() << (attrs.happy? ' :-)' : ' :-(') } } The 'o' of 'out' was missing. Amendmend to avoid misunderstandings: The change from GString to String has nothing to do with the error in the example code.
Hide
Graeme Rocher added a comment -

Assigning all documentation related issues to 1.2 final since they don't represent a change to the codebase

Show
Graeme Rocher added a comment - Assigning all documentation related issues to 1.2 final since they don't represent a change to the codebase
Hide
Graeme Rocher added a comment -

yeh without the parenthesis the example is invalid, but you can't just test the string since "false" will evaluate to true

http://github.com/grails/grails/commit/64a24e166d61fb25d22b2756e99494c60801452d

Show
Graeme Rocher added a comment - yeh without the parenthesis the example is invalid, but you can't just test the string since "false" will evaluate to true http://github.com/grails/grails/commit/64a24e166d61fb25d22b2756e99494c60801452d

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
2m
Original Estimate - 2 minutes
Remaining:
2m
Remaining Estimate - 2 minutes
Logged:
Not Specified
Time Spent - Not Specified