haedes
haedes

Reputation: 622

error creating a custom tag library in Grails

I was trying out a simple use of grails tag library. I created a simple tag library called isowner

class AuthTagLib {
static defaultEncodeAs = 'html'

def springSecurityService

def isOwner = { attrs, body ->
    def loggedInUser = springSecurityService.currentUser
    def owner = attrs?.owner

    if(loggedInUser?.id == owner?.id) {
        out << body()
    }
}}

Then tried using it with the gsp as :

<g:isOwner owner="${leaveFormInstance.employee}">
                    <g:link class="edit" action="edit" resource="${leaveFormInstance}">
                        <g:message code="default.button.edit.label" default="Edit" />
                    </g:link>
</g:isOwner>

Now it was supposed to take a user object as input and validate if user is the owner of the post.

Now everything works fine but in the output html it displays the link as a text. enter image description here

I am new with this stuff and must be missing some basics can you help.

Upvotes: 4

Views: 1121

Answers (1)

Burt Beckwith
Burt Beckwith

Reputation: 75671

Remove

static defaultEncodeAs = 'html'

since that's escaping your output.

Upvotes: 6

Related Questions