Package: groovy.text.markup

## [Groovy] Class TagLibAdapter

- groovy.text.markup.TagLibAdapter

-     class TagLibAdapter
      extends Object

  Adapts Grails taglibs for use in the template engine. An adapter may be created like this:

           def model = [:]
           def tpl = template.make(model)
           model.g = new TagLibAdapter(tpl)
           model.g.registerTagLib(SimpleTagLib)

  where SimpleTagLib is:

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

  Then it can be used inside a template like this:

           g.emoticon(happy:'true') { 'Hi John' }

  Performance-wise, it would be better to reimplement the taglib, but this makes it easier to reuse existing code.

- - ### Constructor Summary

    Constructors
    Constructor and description
    `TagLibAdapter(BaseTemplate tpl)` Creates an adapter bound to the supplied template instance.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `Object` | `methodMissing(String name, Object args)` Dispatches an unknown method call to the first registered tag library exposing a matching closure property.
    `` | `void` | `registerTagLib(Class tagLibClass)` Instantiates and registers a tag library class.
    `` | `void` | `registerTagLib(Object tagLib)` Registers an already-instantiated tag library object.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### TagLibAdapter(BaseTemplate tpl)

      Creates an adapter bound to the supplied template instance.

      Parameters:
        `tpl` - template used to rehydrate invoked tag closures

  - ### Method Detail

    - #### @SuppressWarnings(value="Instanceof")
      Object methodMissing(String name, Object args)

      Dispatches an unknown method call to the first registered tag library exposing a matching closure property.

      Parameters:
        `name` - tag name requested by the template
        `args` - arguments forwarded to the matching tag closure
      Returns:
        the tag library invocation result

    - #### @SuppressWarnings(value="UnnecessaryGetter")
      void registerTagLib(Class tagLibClass)

      Instantiates and registers a tag library class.

      Parameters:
        `tagLibClass` - tag library type whose no-arg constructor should be invoked

    - #### void registerTagLib(Object tagLib)

      Registers an already-instantiated tag library object.

      Parameters:
        `tagLib` - tag library instance to make available to templates