velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrea Sponziello <>
Subject Re: macro does not load first time
Date Thu, 21 Oct 2004 13:20:33 GMT

I read also the mail of Shinobu.

I've a file like this:

---- login.vm ---------------


and in "login_macros.vm" (the file parsed) is defined "showLoginForm()".
This doesn't work.
I see "#showLoginForm()" instead of the rendered form.
#errors() is defined in VM_global_library and works well (is correctly 

The problem is, I think, that I'm using #parse directive to include a 
file that contains macro
declarations. But as I understood reading the User Manual, #parse loads 
the macros but
they will be probabily available only next time that "login.vm" will be 

The User Manual says:

"simply use the |velocimacro.library| facility to have Velocity load 
your VMs at startup"

My problem is that I need to use MANY files with macro declarations. 
This is important for
me because many developers produce macros to obtain more readable files 
and is good for
them storing their macros in different files (one file for each 
developer/module for example).
It is very difficult to share a single "macro-declarations file" in a 
multi-developer environment.

Using, for example, many #parse directives into VM_global_library.vm to 
include, at startup,
external macro files doesn't work. If it works can solve my problems. 
Naturally, the best is
that each developer can store his "macro_declarations files" into a 
folder and include (#parse)
it in every place he needs to use a macro (without modifyng a central 
macro file, and this is
the way #parse directive works in my first analysis of the Velocity 

I also read about this property:

file.resource.loader.path = templates

I put my "macro_declarations files" inside this folder but nothing...

Again, tanks for your time


Terry Steichen wrote:

>If you put your macro at the beginning of your Velocity template, it will run the first
time.  The issue has to do with the sequence of processing, and has been around a long time.
>  ----- Original Message ----- 
>  From: Andrea Sponziello 
>  To: Velocity Users List 
>  Sent: Thursday, October 21, 2004 4:49 AM
>  Subject: macro does not load first time
>  Hi all,
>  I have a problem in using macros in a web application (I use Struts, 
>  Velocity 1.4 and
>  Tomcat 5 as container).
>  When the application Starts/Restarts macros are shown as simple
>  text and are not processed, for example I see:
>  #showMyForm()
>  instead of the form rendered by this macro. If  I do a simple refresh of
>  the page the macro seems loading and is correctly rendered.
>  I made searches in the archives but, due to some problem, I can't read 
>  old mails
>  referring to this problem as I posted a few days ago
>  (subject was: "problems searching user-list archive").
>  Can someone help me? Is this a bug or I misconfigured some option?
>  Tanks for your time,
>  Andrea
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail:
>  For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message