It would b nice to have a JTidy wrapper as a filter example (including configurable options)!
OTOH, I still believe the whitespace handling should be straightened out beforehand. My proposal on this was the "Standalone Directive" (tm) form, which should be treated by velocity as a unit where the surrounding whitespaces are gobbled. This whould make the rules *very* simple and understandable.: -> If a line is looks like this: DirectiveLine ::= LineEnd TabsAndSpaces? Directive TabsAndSpaces? LineEnd TabsAndSpaces ::= (#x20 | #x09)+ LineEnd ::= StartOfStream | ((#x0D #x0A) | #x0D | #x0A) | EndOfStream -> then the first "TabsAndSpaces?" and the closing "TabsAndSpaces? LineEnd" should be gobbled. (Note that it supports multiline directives, that is why "DirectiveLine" is not simply "Line".) * If you want the first "LineEnd" to be gobbled prepend a ## before it (makes it part of the comment on the previous line!). * To have an indented directive remain indented, add a #**# before it; or use a call to a #print( "..." ) macro for explicit output.
BC is mainly kept, since anyone who used indented directives anyway did not care about the stray whitespaces being output. Only bytewise comparing previous and new output would fail (due to less whitespaces).
Cheers, Christoph
Peter Romianowski wrote:
Hi all,
I'd like to propose some kind of filter-mechanism. I did that before, but I think I should do it in an offical way again ;)
The proposal is to include some kind of post-processing filter which alters the generated content. First an example of the possible VTL:
#filter (name [arguments]) #end
Let's take the example of a very anticipated feature (by many users in many different ways): Whitespace-Gobbling. The VTL could look like this:
#filter (whitespace) Hi there ! #end
and would render as: [Hi there !]
Another example would be a Null-Output-Filter which simply suppresses all the output (useful when you have several #set and #if directives):
#filter (null) #set ($a = 1) #if ($a == 1) This will not be written to the output! #end #end
This will render as: []
Many other usecases come into my mind and I think such a filter mechanism would increase the power of velocity dramatically without "sacrificing" the purism.
Configuration:
The filter would be configured in the velocity.properties file like:
filter = null, whitespace
filter.null.class = o.a.v.runtime.filter.NullFilter filter.null.property = additional properties are defined this way filter.whitespace.class = o.a.v.runtime.filter.WhitespaceFilter filter.whitespace.property = additional properties are defined this way
Whereas I think that the Whitespace- and the Nullfilter should be available by default (along with others?).
As an additional benefit this proposal of using filters would end discussions
on things like Whitespace-Gobbling and stuff since you can plug in filters
as you like. And a new slogan could be introduced by the
hardcore-MVC-purist-Velguys besides "Use a Tool(tm)" - "Use a Filter(tm)" ;)
If there is interest I'd like to publish an implementation proposal for this.
But the discussion first.
BTW: Geir, do you have a timeline of releases and features / stuff in it? IIRC
the 1.4dev will go out quite soon and then the 1.4 release (the last w/o Map
and Numbersupport). After that we will go for all the new stuff, right? If you
have some kind of plan - please share it with us.
Regards, Peter
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- :) Christoph Reck
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
