Leon Messerschmidt wrote:
> 
> > Jose Alberto Fernandez wrote:
> > >
> > > The point here is not how to escape but that the regular way to do this,
> > > i.e., pass your value thru a function, or write a macro that calls that
> > > function; they just polute the template and makes the whole thing
> dificult
> > > to read.
> > >
> > > The need is for a mechanism that can perform this transformations
> implicitly
> > > without having to call something everytime we type "${....}".
> > >
> >
> > What's the downside again for postprocessing the rendered stream?  I
> > don't remember...
> 
> If I have a template <text>$name</text> and context.put ("name","<>") the
> output stream looks like this
> 
> <text><></text>
> 
> How do I go from that to this
> 
> <text>&lt;&gt;</text>
> 
> without knowing what was original XML and what was inserted?

Yup, that's an issue.  You would have to make a clueful post processor
that would not convert your tags.

But what if I want to insert :

<parent>
   $xmlblob
</parent>

where 

$xmlblob is "<child>William</child>"

Then the listener approach screws things up too, right?

Now, 

<text>#escape("<>")</text> 

is disliked for some reason. Don't understand why yet.

What about

#macro( node $tag $attr $text)
  #if ($text.length() > 0)
     <$tag $attr />
  #else
     <$tag $attr>#escape($text)</$tag>
  #end
#end

so

#node( "text" "" "<>")

Not as readable, I guess, but does guarantee closed nodes, I guess :)

Just thinking out loud here.

geir

-- 
Geir Magnusson Jr.                               [EMAIL PROTECTED]
Developing for the web?  See http://jakarta.apache.org/velocity/

Reply via email to