The closure template API SoyFileSet.Builder
has several ways to define templates that one wants to use. The one I know how to use is the following:
SoyFileSet sfs = builder.add(new File("...")).build();
There is a second way to create the SoyFileSet
with a template in string form:
add(CharSequence content, String filePath)
This add
method takes a CharSequence
which I presume is the template in string form (the documentation states "Adds an input Soy file, given the file content provided as a string, as well as the desired file path for messages.") I can not figure out what the second parameter is about. I don't need it at the moment. Setting it to null or "" throws an exception. Can anyone share an example on how to properly use the second API?
an example from a groovy script I have
soyFileSetBuilder.add(getFileContent("src/main/resources/soy/$it"), it)
where "it" is the file name. now the reason this is so, is so you can get error messages from the soy compiler. you can make that value whatever you wish, but when dealing with multiple soy files and something goes wrong, you will be happy for sensible values in there.
there is another interesting method for dealing with soyfiles you might have missed: SoyFileSet.Builder addVolatile(File inputFile)