Hi Geir,
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of Geir Magnusson Jr.
>
> Paulo Gaspar wrote:
> >
> > Does someone have a clue on what the problem is?
>
> yes.
LOL, that helps!
=;o)
>...
> > Sorry, but I get so many weird things that I can
> > only describe it this way.
>
> Ok.
>
> > Example:
> >
> > Having the macro:
> >
> > #macro (mymacro $cn $cv)
> > #if($cv)
> > <tr><td>$cn mm</td><td>$cv</td></tr>
> > #end
> > #end
> >
> > and
> >
> > #mymacro($somevar $emptyVar)
> >
> > 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.
> > In the past I already got to see that there seems
> > to exist some wrapper to the parameter variables
> > that is not invisible at all (such wrapper should
> > let us see trough) and messes up this kind of test.
>
> Yes - there is a wrapper. I remember that there was a side effect of
> this, but I thought that behavior was preserved. I will investigate.
I got lost trying to find this one. Could you tell me where
can I find that wrapper?
I want to help fixing this.
> > Also, sometimes code in macros seems to become
> > "persistent" (I change the template but the bit of
> > formatting from inside the macro remains the same.
>
> Yes - by default, the first macro defined is permanent. There are
> plenty of options to change the behavior to suit your need. In this
> case...
I did not find that to be clear in the documentation. But
maybe I did not read with enough attention.
The documentation talks about macros that can be registred
for global use and so, but I always thought that macros
declared in one template would be used only by that template.
Do you mean that Velocity only has GLOBAL macros???
Can that be changed?
> velocimacro.permissions.allow.inline.to.replace.global = true
>
> will fix it.
Does that replace the global macro GLOBALLY or just for the
current template?
> > Does anyone have any pointers on this stuff?
> > Any clues?
> > Any advise on where I should start trying to fix this?
>
> Well, reading the manual in the case of the macro persistance might have
> given you a clue. I have been wanting to write something more
> substantial about the VMs, so I guess this motivates me to do it.
Didn't.
Maybe I did not pay enough attention, but I had the idea that macros
declared in a template would be for the private use of that template and
when I found the reference to global macros in the docs I just understood
that those had to be registered somehow - which was not interesting for
my case.
This is the most intuitive working model. Other engines work that way.
The only problem I see with the documentation (which is DAMN GOOD and is
clearly improving all the time) is that it does not make this less usual
working model clear upfront.
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.)
> > Does downloading the last version solve it all?
> > (wishful thinking!)
>
> No. The VM code has been very stable - the only change recently had to
> do with 'local scope' namespaces, totally unrelated to this.
Thanks. My version is only a couple of weeks old.
> > Sorry about the sarcastic mood, but I already spent
> > too much time with this. I am willing to turn by
> > agressivity into solving this, but pleaaaase give
> > me a clue. (I don't even know if I have to start
> > learning JavaCC or if I can still void that.)
>
> Why didn't you just ask?
Sorry Geir. I did not sleep yesterday and was 30 hours at the computer.
It is not your fault and I should not be so agressive.
The whole thing was just not making sense and I always think that the
problem should be in my code first. That is why I kept insisting before
talking.
It just seems to happen that I use the templates in a different way,
and that is how I seem to be the only one finding these things.
Thank you and the rest of the team for the great work and the great
documentation. From all the Open Source stuff that I use, Velocity is
by far the best documented.
Please remember to tell me where can I find that wrapper object
mentioned above.
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.
This sounds more intuitive. I will contribute to it... unless there
is a reason against.
Thank you very much and have fun,
Paulo Gaspar