ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Harvey <oz.robhar...@gmail.com>
Subject Any use for an optional template copy task?
Date Thu, 17 Nov 2005 23:46:37 GMT
Hi,
I wrote a Task recently that alters files as they are copied to
different directories. I used it to create a website and it serves we
quite well - I imagine it would be useful for other applications where
more complex copying operations are required.
It basically works like this:
        <taskdef name="tcopy" classname="TemplateCopy" classpath="."/>
        <tcopy templatefile="${tfile}" outdir="${outdir}" srcdir="${srcdir}">
          <include name="**/*.tmpl"/>
        </tcopy>
        <tcopy templatefile="${jsfile}" outdir="${outdir}"
srcdir="${srcdir}" ext=".js">
          <include name="rolling.tmjs"/>
        </tcopy>

What it is saying is, for every file in the include list, make a token
replacement copy of the file "templatefile" to "outdir" with the
appropriate extension. So if srcdir contained 10 *.tmpl files, then 10
files (with the default *.html extension) will end up in the outdir
location, where the values in the *.tmpl files are inserted into the
base "templatefile".

In other words, I have one templatefile that contains generic
information plus some tokens:
 <html>
  <head>
   <title>@TITLE@</title>
  </head>
  <body>
   <h1>Some general info</h1>
   @CONTENT@
  </body>
 </html>

and then some others - let's say "welcome.tmpl" - that contain only
token, value pairs:

@TITLE@
  Welcome page
@CONTENT@
    <p>Welcome to my page</p>

Then the resulting page would be "welcome.html" in the outdir directory.

Is there any interest in including this with optional tasks?

 -rob

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message