velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Kienenberger <mkien...@alaska.net>
Subject Re: Avoiding Line Breaks in macros
Date Thu, 14 Oct 2004 22:10:31 GMT
Alexandre Torres <alexandre.torres@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


Mime
View raw message