velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christoph.R...@dlr.de
Subject Re: Formatting Issue (Whitespace)
Date Tue, 26 Nov 2002 19:46:40 GMT
Hi Alexandre,

the workaround to omit stray whitespaces in the output is to use
comments spanning the EOL and whitespaces:

#macro( button $index )#*
   *##if( $menu.size() > $index )#*
     *##set( $buttontext = $menu.elementAt($index).alttext )#*
     *#<A HREF="${menu.elementAt($index).link}">#*
       *#<IMG SRC="${req.contextPath}/button_factory?#*
          *#textColor=FFFFFF&bgColor=${accentcolor}#*
          *#&text=${utils.escapeForURL($buttontext)}">#*
     *#</A>#*
   *##else#*
     *#&nbsp;<!-- empty button -->#*
   *##end#*
*##end

I know this is not vey pretty, but it works. I have posted a proposal
to fix this in velocity, but it has not reached a consensus (will it ever?).

P.S. I see that you are using a button factory, is this based on my code? Cheers!
      As I've stated somewhere in some list the past (turbine, velocity, other?),
      it is intended to be published, can someone take a lead on this to get it
      into jakarta or sourceforge? I could also do this if someone points me in
      the right direction (jakarta account?).

--
:) Christoph

Alexandre Martin wrote:
> I have the following two macros. The content output is fine but the formatting is not
how I want it. 
> 
> How can I modify my macros to output the content in the desired format (see below)?
> 
> 
> #macro(button $index)
>     #if($menu.size() > $index)
>         #set($buttontext = $menu.elementAt($index).alttext)
>  <A HREF="${menu.elementAt($index).link}"><IMG SRC="${req.contextPath}/button_factory?textColor=FFFFFF&bgColor=${accentcolor}&text=${utils.escapeForURL($buttontext)}"></A>
>     #else
>  &nbsp;<!-- empty button -->
>     #end
> #end
> #macro(imenu $startindex)
>     #if($menu.size() > $startindex)
>         <TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="600" BORDER="0">
>                 <TR>
>                     <TD>#button($startindex)</TD>
>       #set($startindex = $startindex + 1)
>                     <TD>#button($startindex)</TD>
>                     #set($startindex = $startindex + 1)
>                     <TD>#button($startindex)</TD>
>                     #set($startindex = $startindex + 1)
>                     <TD>#button($startindex)</TD>
>                     #set($startindex = $startindex + 1)
>                     <TD>#button($startindex)</TD>    
>                 </TR>
>         </TABLE>
>     #end
> #end
> 
> 
> Current Output:
> 
>     <TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="600" BORDER="0">
>  <TR>
>      <TD WIDTH="89" BGCOLOR="#990000">            <A HREF="menu0link"><IMG
SRC="/button_factory?textColor=FFFFFF&BGCOLOR=990000&text=Search"></A>
> </TD>
>     <TD WIDTH="89" BGCOLOR="#990000">            <!-- empty button -->
> </TD>
>     <TD WIDTH="89" BGCOLOR="#990000">            <!-- empty button -->
> </TD>
>     <TD WIDTH="89" BGCOLOR="#990000">            <!-- empty button -->
> </TD>
>     <TD WIDTH="90" BGCOLOR="#990000">            <!-- empty button -->
> </TD>    
>  </TR>
> </TABLE>
>         
> 
> Desired Output:
> 
> <TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="600" BORDER="0">
> <TR>
>     <TD WIDTH="89" BGCOLOR="#990000"><A HREF="menu0link"><IMG SRC="/button_factory?textColor=FFFFFF&BGCOLOR=990000&text=Search"></A></TD>
>     <TD WIDTH="89" BGCOLOR="#990000"><!-- empty button --></TD>
>     <TD WIDTH="89" BGCOLOR="#990000"><!-- empty button --></TD>
>     <TD WIDTH="89" BGCOLOR="#990000"><!-- empty button --></TD>
>     <TD WIDTH="90" BGCOLOR="#990000"><!-- empty button --></TD>   

> </TR>
> /TABLE>
> 

-- 
:) Christoph Reck


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


Mime
View raw message