Nesting custom tags in grails

Posted By : Abhinav Anand | 27-Dec-2014

There are so many cases in which we have to use custom tags and in which we have to use more than one tag at a time; we can say tag nesting. Here I am going to use two custom tags at the same time as per our nee.

You can create your TagLib class in which you can create custom tags.  Like  :

def formatAmount={attrs, body->
		def amount = attrs?.amount
		def formatedAmount = String.format("%,.2f",amount)
		if(formatedAmount.contains('.00')){
			out<

and another as

def netAmount={attrs, body->
		def amount = attrs?.amount
	    def interestRate=attrs?.interestRate
        def netAmount=amount+(amount*interestRate)/100
			out<

And here is the nested tag in view


${amount}

Thanks

About Author

Author Image
Abhinav Anand

Abhinav is a bright web developer with expertise in groovy and grails frameworks. His hobbies are listening music and playing cricket.

Request for Proposal

Name is required

Comment is required

Sending message..