Test Link
(based on Tomás Lin’s truthlink)
This is useful when one requires link on certain condition.
Instead of first using condition tag and then tag for link these can be combined into one using taglib.
 
     
	text 
      
  
or
   
    
     Text 
    
  
Other way of doing this is by using taglib.
class AbcTagLib {
namespaces "abc";
    def testLink = {attrs, body ->
        String attributes = ''
        if (attrs['test']) {
            attrs.remove('test')
           if (attrs.keySet().contains("action") || attrs.keySet().contains("controller")) {
                out << g.link(attrs, body)
            } else {
                attributes = "${attrs.collect {k, v -> " $k=\"$v\"" }.join('')}>"
                out << ""
            }
        } else {
            out << body()
        }
    }
}
Now since the Tag is created condition test and and link can be combined into one
text                                        
 
or
 
     Text 
 
_____________________
Hitesh Bhatia
hitesh@intelligrape.com
_____________________
 
     
					 
							
Nice blog. Specially for the statement :
attributes = “${attrs.collect {k, v -> ” $k=”$v”” }.join(”)}>”
This statement is excellent which outputs all the attributes in a string irrespective of the no. of attributes passed with the tag.