Search code examples
grailsgsp

Postprocess *.js files with grails


I am wondering of there is any possibility of postprocessing *.js files so that every gsp expression can be evaluated.

for example i can write the following code directly in the gsp page:

<script type="text/javascript">
$.post("${createLink(controller:'mycontroller',action:'myaction')} " , {"id":id},function(){});
</script>

And the expression ${createLink} is evaluated by grails.

But i would like to also use ${createLink()} in *.js files which are not processed by grails. Maybe it is possible to use the resource plugin to postprocess every *.js file and evaluate gsp expressions?

Of course i could wrap all my js code in a separate gsp page but it does not seem like an elegant solution.

Any help would be appreciated.


Solution

  • Either of this should work for you