Last active
December 14, 2015 23:28
-
-
Save chiquitinxx/1851d1bdb5a71980bab6 to your computer and use it in GitHub Desktop.
Groovy components coming in grails 3 plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Define your component in a groovy class | |
package foo.bar | |
class Counter { | |
static renderAfter = ['inc', 'dec'] | |
static style = 'button { background-color: red; }' | |
int value = 0 | |
void inc() { | |
value++ | |
} | |
void dec() { | |
value-- | |
} | |
void render() { //Markup template engine | |
h1 value.toString() | |
p { | |
button(onclick: 'dec', '-') | |
button(onclick: 'inc', '+') | |
} | |
} | |
} | |
//Add to your gsp's with: | |
<grooscript:component src='foo.bar.Counter'/> | |
//And then use in your gsp | |
<counter></counter> | |
<counter value="5"></counter> | |
//Not using implementations as React or Polymer. Just using custom components and shadow dom (http://webcomponents.org/) | |
//The idea, is the component renders when you change something visual or important |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment