# formatBoolean

## Purpose

Outputs the given boolean as the specified text label.

## Examples

    <g:formatBoolean boolean="${myBoolean}" />
    <g:formatBoolean boolean="${myBoolean}" true="True!" false="False!" />

## Description

Outputs the given boolean as the specified text label. If the <code>true</code> and <code>false</code> option are not given, then the boolean is output using the default label.

Attributes:

`boolean` - the boolean to output `true` (optional) - text label for boolean true value . `boolean.true` or `default.boolean.true` key is looked up from the Message Source / ResourceBundle (i18n/*.properties) if this attribute is not given. `false` (optional) - text label for boolean false value . `boolean.false` or `default.boolean.false` key is looked up from the Message Source / ResourceBundle (i18n/*.properties) if this attribute is not given.

## Source

Show Source

    def formatBoolean = { attrs ->
             if (!attrs.containsKey("boolean"))
                 throwTagError("Tag [formatBoolean] is missing required attribute [boolean]")         def b = attrs.get("boolean")
             if (b == null) {
                 return null
             }
             else if (!(b instanceof Boolean)) {
                 b = Boolean.valueOf(b)
             }         def locale = resolveLocale(attrs.get('locale'))
             if (b) {
                 return attrs["true"] ?: messageHelper('boolean.true', { messageHelper('default.boolean.true', 'True', null, locale) }, null, locale)
             }
             else {
            	 return attrs["false"] ?: messageHelper('boolean.false', { messageHelper('default.boolean.false', 'False', null, locale) }, null, locale)
             }
         }