on 12/1/2000 2:09 PM, "Jose  Alberto Fernandez" <[EMAIL PROTECTED]>
wrote:

> Well, I could argue that the need for encoding is part of the View and
> not of the model or the controler. In other words, if I where in need to
> generate some other text format, which I can do using Vel, I should not
> need to change my model. I would expect I can use "$x.getFieldwithText()"
> and this time getting not escaped output.

Ok, so then what is wrong with:

$escape.getText($x.getFieldWithText())

You just went full circle on yourself dude.

:-)

> True, but what I am suggesting is that only "variable"/"method" output
> be filtered. Not the template itself (the argument being that template
> encoding is for the writer of the template to do).
> 
> If the filters can be installed dynamically, it would be up to
> the script to control it. For example, lets assume there is a directive
> #filter the argument being an object implementing certain interface:
> 
> XMLScript.vtl
> 
> #filter($filter)
> <?xml ...?>
> 
> <stuff>
> $x.getValue()
> <cdatastuff>$filter.turnOff()<![CDATA[>
> here goes unscaped stuff & this happens because I dynamically
> switched off my filter, because I ddesigned it that way.
> <!]]>$filter.turnOn()</cdatastuff>
> More filtered stuff for $y here.
> </stuff>
> 
> So what do you think, what I am asking is a definition and way
> to set this filter interfaces, it is up to the developer to provide
> the smarts required by it.

You can do all of that without any modifications to Velocity.

> public class XMLFilter implements Filter
> {
> private boolean off = false;
> 
> public String process(String in) { //Filter interface
> if (off) return in;
> return Escape.getText(in);
> }
> 
> public void turnOn() { off = false; }
> public void turnOff() { off = true; }
> }

turnOn/turnOff? Huh? How about:

public void enabled(boolean value)

-jon

-- 
twice of not very much is still a lot more than not very much

Reply via email to