velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Dekany" <ddek...@freemail.hu>
Subject Re: Whitespace, redux
Date Wed, 10 Apr 2002 22:20:09 GMT
----- Original Message -----
From: "Jim Rudnicki" <jdr5list@pacbell.net>
To: "Velocity Users List" <velocity-user@jakarta.apache.org>
Sent: Wednesday, April 10, 2002 10:50 AM

[snip]
> This whole problem strikes me as something that is not an issue for the
> parser at all.  I like Geir's position that the parser just sees a
character
> stream.  To that end, it already does too much by eating some line ends.

Despite of my previous letter I like this approach,  but then Velocity
should support pluggable preprocessors... but see bellow.

> You're problem and many other similar ones could be resolved with a
> preprocessor that converts from what the developer likes to type to what
the
> parser should see.  Couldn't this easily be done with a
> MyWhitespaceResolvingFileResourceLoader ?  With this approach everyone who
> needs to have their own code format be interpreted as something else just
> make a JoeSmoesFileResourceLoader.
[snip]

The problem here is that you try to do the preprocessing with the resource
loader. This is IMO awkward since resource loader is to load raw byte
streams, and it should not deal with the meaning of that byte stream. One
problem caused by this is that you have to know the charset of temaplate or
else you can't interprete and preprocess it. And AFAIK this (i.e. choosing
the charset) hapens independently of the resource loader. Then, you still
must return a byte stream so you have to encode the text back to byte
stream.

I think the solution would be pluggable template preprocessors. This will be
useful for implementing JSP custom tag style tool calls too.
I have looked into the soruce code (sorry if I have misinterpreted it, this
was just a quick action...) and the Template class I see this:

  is = resourceLoader.getResourceStream(name);
  ... // snip
  BufferedReader br = new BufferedReader( new InputStreamReader( is,
encoding ) );
  data = rsvc.parse( br, name);

My idea with pseudo code is that:

  BufferedReader br = new BufferedReader(myPluggabeParser.getReader( is,
encoding ) );

where the myPluggabeParser comes from the runtime configuration. So that I
can preprocess templates in a obvious and efficient way.


--
To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>


Mime
View raw message