How can I declare a function inside GSP? I need something like taglib but declared inside GSP - it doesn't matter outside
You can't define methods in GSPs. But you can have anonymous functions if you want :D
Example:
<%
def prettify = { "***$it***" }
%>
<h1>${prettify(someText)}</h1>
Though this example doesn't make too much sense, as that little formatting could be inlined. For any kind of extra logic for the views, I would follow OverZealous recommendation and use a taglib.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With