I would like to generate a file from an intermixed content of inline code snippets and contents of other files. Something like:
<target name="generate-js-function">
<concat destfile="mycode.js">
<header trimleading="yes">
// begin auto generated
var create = function() {
function createHtmlSnippet1() {
</header>
<fileset file="snippet1.js"/>
<header>
}
</header>
<header trimleading="yes">
// begin auto generated
var create = function() {
function createHtmlSnippet2() {
</header>
<fileset file="snippet2.js"/>
<header>
}
</header>
return '' + createHtmlSnippet1() + createHtmlSnippet2();
}
// end auto generated
</header>
</concat>
</target>
AFAIK, there can be only one header / footer, so what’s the proper way to do it?
Update: if anything in the question isn’t clear – please ask – I’ll clarify happily.
For the inline snippets you can use the
stringresource:The only downside is that it doesn’t support the
trimleadingattribute, but it will allow you to have the code inline in your build file.