Apr 3, 2011

greenscript-1.2d released

There are a couple of new features released on this version (v1.2d):

1. Resource and dependency management in modules
Now you are able to manage your javascript and css files in modules. Meaning you could be able to create a "greenscript.conf" file in your ${module.root}/conf folder, put javascript and css files in ${module.root}/public/(javascripts|stylesheets} folders and reuse them with any play applications.

2. Inline dependency declaration in tags
There is a long time complaint about greenscript that the sequence of declared resources in tag does not get kept when those resources are output to html page. Now with inline dependency declaration feature, the inconvenience is largely removed. E.g.

#{greenscript.js 'myapp < mylib < jquery-1.4.4.min' /}

A tag declaration like above automatically set the dependence graph between myapp.js, mylib.js and jquery-1.4.4.min.js. I.e. myapp.js relies on mylib.js, which in turn relies on jquery-1.4.4.min.js. You don't need to be forced to create conf/greenscript.conf to declare the dependencies.

This feature is very useful for those application with relatively simple resource dependencies.

3. Reverse dependence declaration in greenscript.conf file
This is actually a feature added since v1.2c. Usually you declare dependency relationship in greenscript.conf file as follows:

js.myapp=mylib1,mylib2

which means myapp.js relies on both mylib1.js and mylib2.js. However with reverse dependence declaration, you switch the dependency relationship arrow:

js.mylib1-=myapp1,myapp2

meaning both myapp1.js and myapp2.js relies on mylib1.js. This feature makes it convenient to declare dependency relationships associated with things like jquery:

js.jquery-1.4.4.min-=jquery-ui-1.8.9.min,jquery-validate.min,jquery-tmpl.min

Note to declare reverse dependence relationship, you put a 'hyphen' right left to 'equal' sign in the statement.

4. support '.bundle' suffix
The '.bundle' suffix could be used in greenscript.conf dependence relationship declarations. E.g.

js.common.bundle=mylib1,mylib2,mylib3...
js.common.bundle-=myapp1,myapp2...
...

In the above example, 'common.bundle.js' is not a real javascript file. It's merely a symbol represent a group of resources (mylib1.js, mylib2.js, mylib3.js ...).

This feature makes it convenient to group your resources. It could also be used to create alias for resources that might be updated due to new version, e.g.

js.jq.bundle=jquery-1.4.4.min
js.mylib1=jq.bundle,...

In the above example, you create an alias 'jq.bundle' for jquery-1.4.4.min, which could be easily updated to jquery-1.5.2.min in your greenscript.conf file.

In summary, the new version of greenscript continue to move ahead in the way to make developer's life more easier and more interesting.