You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Alexandre Torres <al...@gmail.com> on 2004/10/14 23:51:47 UTC

Avoiding Line Breaks in macros

Hi.
It is possible to avoid line break generation when calling a macro?
for example:
#macro (duh)
John
#end
...
after the joke #daa() said duh.
...
This will generate:

after the joke John             <---line break
said duh.

I'm trying to generate no HTML content, so, it will be important to
control line break and space generation. I took a look in the docs,
but can't find much about this.
Should I use classes instead of macros (well, macros are much better in my case)

I 'm a little bit lost in this line break generation with #comands
too, I did search in the past messages but it's hard to find
information (or I'm too newbie in velocity).

Thanks for any tip.

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: Avoiding Line Breaks in macros

Posted by Mike Kienenberger <mk...@alaska.net>.
Alexandre Torres <al...@gmail.com> wrote:
> Hi.
> It is possible to avoid line break generation when calling a macro?
> for example:
> #macro (duh)
> John
> #end
> ...
> after the joke #daa() said duh.
> ...
> This will generate:
> 
> after the joke John             <---line break
> said duh.
> 
> I'm trying to generate no HTML content, so, it will be important to
> control line break and space generation. I took a look in the docs,
> but can't find much about this.
> Should I use classes instead of macros (well, macros are much better in my 
case)
> 
> I 'm a little bit lost in this line break generation with #comands
> too, I did search in the past messages but it's hard to find
> information (or I'm too newbie in velocity).
> 
> Thanks for any tip.

I find whitespace in velocity confusing and somewhat inconsistent.

Two general rules are:

Whatever line breaks you put in are left in.
If a line ends with a #command, the line break is not displayed.

So,

#macro(duh)John#end

is what you want.


Your best bet is to play around with stuff until it does what you want it to 
do.
Another useful thing you might need is "#**#" which is an empty inline 
comment that you can use to separate other commands and variables.

One thing to watch out for is that ending the final line with ## will cause 
a fatal error.

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org