And when it comes to elements such as style sheets, I would recommend creating a simple tag that will do the trick, something like these lines:
class StylesTagLib { static namespace = "g" def stylesheet = { args, body -> out << """<link rel="stylesheet" href="${resource(dir: 'css', file: args.href)}"/>""" } }
and then in your code use it like this:
<g:stylesheet href="main.css"/>
Obviously, you can play with conventions (should I use a predefined folder? Should I automatically add the .css extension?), But the general idea is to hide the ugliness behind a beautifully defined tag.
Matthias hryniszak
source share