You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by ge...@apache.org on 2002/02/07 06:40:30 UTC

cvs commit: jakarta-velocity-dvsl/src/java/org/apache/tools/dvsl DVSLTask.java

geirm       02/02/06 21:40:30

  Modified:    src/java/org/apache/tools/dvsl DVSLTask.java
  Log:
  Added the insertion of a user context - and in that put the current
  input filename and output filename so it can be accessed from within
  the stylesheet when rendering
  
  Revision  Changes    Path
  1.3       +12 -0     jakarta-velocity-dvsl/src/java/org/apache/tools/dvsl/DVSLTask.java
  
  Index: DVSLTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity-dvsl/src/java/org/apache/tools/dvsl/DVSLTask.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DVSLTask.java	6 Feb 2002 04:47:12 -0000	1.2
  +++ DVSLTask.java	7 Feb 2002 05:40:30 -0000	1.3
  @@ -257,6 +257,18 @@
                   writer = new BufferedWriter( new FileWriter( outfile ) );
   
                   /*
  +                 *  add a user context so we can store the current input
  +                 *  and output filename, which must be interesting to know
  +                 */
  +
  +                VelocityContext userContext = new VelocityContext();
  +
  +                userContext.put("inputfilename", infilename);
  +                userContext.put("outputfilename", outfilename);
  +
  +                dvsl.setUserContext( userContext );
  +
  +                /*
                    *  do the transformation
                    */
                   
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-velocity-dvsl/src/java/org/apache/tools/dvsl DVSLTask.java

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 2/7/02 12:59 AM, "Jon Scott Stevens" <jo...@latchkey.com> wrote:

> on 2/6/02 9:40 PM, "geirm@apache.org" <ge...@apache.org> wrote:
> 
>> +                VelocityContext userContext = new VelocityContext();
>> +
>> +                userContext.put("inputfilename", infilename);
>> +                userContext.put("outputfilename", outfilename);
>> +
>> +                dvsl.setUserContext( userContext );
> 
> May I suggest that if you are going to go this route that you create a $dvsl
> tool and add that to the context and then provide methods
> getInputFilename(), getOutputFilename()?
> 
> The reason is that once you start down this route, it is easier to point
> people at the javadoc for $dvsl than it is to document each and every item
> you put into the context. It is also easier to keep track of what is in the
> context...
> 

Good point, I thought about this when doing it, and needed something to test
some ideas.

The problem is that DVSL doesn't really operate on files, it operates on a
Reader and outputs to a Writer for the most part.

The Ant task is just a shell.

So the concept of 'filename' doesn't make sense to DVSL proper.

I still think that from DVSL's point of view, this is a 'user context'
issue.

Hm. :)


(Point well taken though... I don't like magic context keys either...)

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
Be a giant.  Take giant steps.  Do giant things...


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-velocity-dvsl/src/java/org/apache/tools/dvsl DVSLTask.java

Posted by Jon Scott Stevens <jo...@latchkey.com>.
on 2/6/02 9:40 PM, "geirm@apache.org" <ge...@apache.org> wrote:

> +                VelocityContext userContext = new VelocityContext();
> +
> +                userContext.put("inputfilename", infilename);
> +                userContext.put("outputfilename", outfilename);
> +
> +                dvsl.setUserContext( userContext );

May I suggest that if you are going to go this route that you create a $dvsl
tool and add that to the context and then provide methods
getInputFilename(), getOutputFilename()?

The reason is that once you start down this route, it is easier to point
people at the javadoc for $dvsl than it is to document each and every item
you put into the context. It is also easier to keep track of what is in the
context...

-jon


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>