I'm using Plovr and would like to use my own custom function (specifically a ucfirst function) inside templates. At the moment I'm only interested in rendering the templates as javascript, and since this is a fairly simple case I think actually writing the code shouldn't be too much of an issue (using a Plovr-included custom function as a starting point).
The question then becomes: how do I build it and use it with Plovr?
First, you should look at the soy-function-plugins plovr option, if you have not already.
As shown in the example, you need to create a Guice module that loads the classes for your custom functions (such as PlovrModule.java). The example from the options page works without any extra work because org.plovr.soy.function.PlovrModule
is already in plovr.jar
, so it is already on the classpath when you run plovr. If your AbstractModule
/SoyJsSrcFunction
is compiled into another jar, such as my-soy.jar
, then you also need to be sure to include it on the classpath when running plovr:
java -classpath my-soy.jar:plovr.jar org.plovr.cli.Main path/to/config.js OPTIONS
soy-function-plugins was introduced in the February 2011 plovr release.