Groovy web console

subscribe to the feed Subscribe
to this
site
Wro grails DSL (via #groovywebconsole)
tweet this snippet Tweet
this
script

Wro grails DSL

Published 6 years ago by Filirom1 with tags wro4j dsl grails
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
import static WroModelDelegate.*

/* PLAY HERE */
groups{
  all{
    css("/css/*.css")
    js(minimized: false, "/js/*.js")
  }
  "a-sub-set"{
    css("/css/subset.css")
  }
}

/* A Dummy implementation of Wro DSL */

class WroModelDelegate{
  static void groups(Closure cl){
    cl.delegate = new GroupDelegate()    
    cl.resolveStrategy = Closure.DELEGATE_FIRST
    cl()  
  }

}

class GroupDelegate{
  def methodMissing(String name, args) {
    println name
    def cl = args[0]
    cl.delegate = new ResourceDelegate()    
    cl.resolveStrategy = Closure.DELEGATE_FIRST
    cl()
  }
}

class ResourceDelegate{

  void css(Map params = [:], String name){
    println "  CSS $params , $name"
  }

  void js(Map params = [:], String name){
    println "  JS $params , $name"
  }
}