## 6.2.2.6 Tags as Method Calls

One major different between GSP tags and other tagging technologies is that GSP tags can be called as either regular tags or as method calls from either controllers, tag libraries or GSP views.

#### Tags as method calls from GSPs

When called as methods tags return their results as a String instead of writing directly to the response. So for example the createLinkTo tag can equally be called as a method:

    Static Resource: ${createLinkTo(dir:"images", file:"logo.jpg")}

This is particularly useful when you need to use a tag within an attribute:

    <img src="${createLinkTo(dir:'images', file:'logo.jpg')}" />

In view technologies that don't support this feature you have to nest tags within tags, which becomes messy quickly and often has an adverse effect of WYSWIG tools such as Dreamweaver that attempt to render the mark-up as it is not well-formed:

    <img src="<g:createLinkTo dir="images" file="logo.jpg" />" />

#### Tags as method calls from Controllers and Tag Libraries

You can also invoke tags from controllers and tag libraries. Tags within the default `g:` namespace can be invoked without the prefix and a String result is returned:

    def imageLocation = createLinkTo(dir:"images", file:"logo.jpg")

However, you can also prefix the namespace to avoid naming conflicts:

    def imageLocation = g.createLinkTo(dir:"images", file:"logo.jpg")

If you have a custom namespace you can use that prefix instead (Example using the FCK Editor plugin):

    def editor = fck.editor()