Paulo Gaspar wrote:
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> > Behalf Of Geir Magnusson Jr.
> >
> > Paulo Gaspar wrote:
> >
> > > > > something gets written all the time, even if the
> > > > > $emptyVar is really "empty".
> > > >
> > > > Can you define empty? You mean not in the context?
> > >
> > > Usually it is an expression like:
> > > $someObject.property
> > >
> > > And in most cases, the object is a ResultSet wrapper with has
> > > a method looking like:
> > > public Objec get(String i_name)
> > >
> > > The problem is when this method returns null.
> >
> > Ok. That's better.
>
> Give me some pointers. I would like to understand how that works even
> if you fix it by yourself.
>
> > ... (Lots of good stuff that makes almost everything clear to me) ...
> >
> > > I still think that this is the most intuitive way to have macro
> > > functionality. Why is it not that way?
> > > (Just want to understand if there is a reason.)
> >
> > The model it has is because of the way it evolved - we always tried to
> > remain backwards compatible when we relized the problems in the model.
>
> Careful. I sure understand the motivation but some things are better fixed
> early or they become unwanted bloat.
There is nothing to be *fixed*. You are unhappy because of the
*default* was maintained for backwards compatibility....
>
> > > I would also like to know if we could have global macros being
> > > explicitly declared (and changed with each page change) or globally
> > > available trough some registration/magic-file-or-directory mechanism.
> >
> > You can :
> >
> > 1) Have global ones set at startup, and no one else can add.
> >
> > 2) Have global ones set at startup, others can add only new ones
> >
> > 3) Have global ones set at startup, and modified by others during
> > runtime.
> >
> > 4) Have global ones set at startup, no new global ones at runtime, but
> > template-local ones at runtime.
>
> 4 is PERFECT to me.
> What about copying and pasting the above, together with the necessary
> settings into the docs if you are going to "fix" them? That would make
> their working model crystal clear.
Excellent. Will do!
>
> Anyway, I must repeat that Velocity is by far the better document Open
> Source package I use. It is also much better than some commercial
> software I used in the past. (I mostly use OS these days.)
>
> > I can't think of a way to have runtime-modified globals while
> > template-local in effect w/o changing the template syntax so you can
> > indicate namespace, something I believe isn't the right thing to do in
> > VTL.
>
> No, no. That would be unnecessary complexity.
>
> But are local templates with the same name as the global templates
> allowed and used (locally) instead of the global ones?
Yes! It lets you do really cool things - you can do local overrides.
Assume two global VMs, #global1() and #global2().
#macro( global2 $a)
$a
#end
#macro(global1 $a)
#global2($a)
#end
You can 'override' global2 by simply defining one (called global2) in
your template with local scope, and then calling #global1() - your
version should be called.
I found this very cool - I noted it to the list, but didn't document as
it's a bit advanced :) Just getting people to accept VMs is tough
enough.
geir
--
Geir Magnusson Jr. [EMAIL PROTECTED]
System and Software Consulting
Developing for the web? See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!