chiquitinxx / grooscript-plugins

Grooscript plugins - Gradle and Grails 3
12 stars 1 forks source link

Code Exporting #12

Open NomNuggetNom opened 7 years ago

NomNuggetNom commented 7 years ago

I'm not sure this is totally possible, so bear with me. Let's say we have a simple utility class on the back-end:

package util

class Util {
   static String shout(s) { 
      s.toUppercase()
   }
}

And let's say I want to auto-magically use this script on the front end, as such:

<grooscript:code>
   def s = util.Util.shout('Hello, world!')
</grooscipt:code>

In order to get this variable bound in the grooscript context, a simple annotation is introduced, @ExportScript. Simply tagging the class with this annotation will result it in being present on the front-end.

chiquitinxx commented 7 years ago

So, imagine you annotate classes with @ExportScript, then what plugin do? Add that js converted code to all gsp's with grooscript tags?

Can you please explain a bit more this improvement, it seems nice idea!

NomNuggetNom commented 7 years ago

Yes @chiquitinxx exactly :). The classes annotated would be usable within the grooscript:code tag