8.3.5 Tag Namespaces 3.1.10

See the light - agile, industrial strength, rapid web application development made easy

(Quick Reference) # 8.3.5 Tag Namespaces - Reference Documentation Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith, Lari Hotari Version: 3.1.10 ## 8.3.5 Tag Namespaces By default, tags are added to the default Grails namespace and are used with the `g:` prefix in GSP pages. However, you can specify a different namespace by adding a static property to your `TagLib` class:

    class SimpleTagLib {
        static namespace = "my"    def example = { attrs ->
            …
        }
    }
Here we have specified a `namespace` of `my` and hence the tags in this tag lib must then be referenced from GSP pages like this:
    <my:example name="..." />
where the prefix is the same as the value of the static `namespace` property. Namespaces are particularly useful for plugins. Tags within namespaces can be invoked as methods using the namespace as a prefix to the method call:
    out << my.example(name:"foo")
This works from GSP, controllers or tag libraries | Quick Reference (hide)