Error creating custom tag library in Grails

I tried a simple use of the 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 gsp like:

<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 he had to take the user object as input and check if the user is the owner of the message.

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

I am new to this material and should be missing some basics, you can help.

+4
source share
1 answer

Delete

static defaultEncodeAs = 'html'

as this eludes your conclusion.

+6
source

All Articles