Hamila Mohamed Amine
Hamila Mohamed Amine

Reputation: 290

using a resource inside a taglib definition in grails?

I’m new to grails and I want to write a taglib but I can't figure out how to reference a resource inside the MyTagLib.groovy file. The resource that I want retrieve the path is a picture. I tried something like what I used to do in the gsp file like this:

< g:resource dir="images/icons/flag-icons/" file="gb.png" />

and this

${resource(dir: 'images/icons/flag-icons/', file: 'gb.png')}

But it doesn’t work

Upvotes: 0

Views: 724

Answers (1)

Rhysyngsun
Rhysyngsun

Reputation: 951

Taglibs are available from within other taglibs (and controllers) via a variable matching their namespace (the value of the static namespace field). In the case of Grails' built-in taglibs:

g.resource(dir: 'images/icons/flag-icons/', file: 'gb.png')

Upvotes: 1

Related Questions