You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by piero de salvia <pi...@yahoo.com> on 2001/07/25 17:10:53 UTC

VTL question

Hi all,

I was trying to implement the ever present altbgcolor
macro, to make my table rows white and grey, so i
wrote this:

#macro( altbgcolor $RowCount)
	#if ( ($RowCount%2) == 1 )
		#ffffff
	#else
		#d3d3d3
	#end
#end

and I called it from a loop as 
#altbgcolor(velocityCount)

surprise!
a nice /n is output after the color, and, after having
gone through the archives, it seems to me that my only
choice is this:
#macro( altbgcolor $RowCount)
#if ( ($RowCount%2) == 1 ) #ffffff #else #d3d3d3 #end
#end

rather ugly, plus if the macro is complicated, this is
tantamount to writing it in bytecode...

how did you guys do (or hack)  it ?

piero de salvia

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

Re: VTL question

Posted by Richard Neish <ri...@rmp.com.jm>.
Dan,

I guess your suggestion below could work for substitutions made
by Velocity, but to my mind this is NOT a Velocity problem.  In
the same way that I like to format VTL for readability, I like to
put whitespace and indentation in HTML.  What would solve my
problems is an inline version of HTML tidy by the W3 group which
removes whitespace from HTML to reduce its size.

Maybe a concrete example would be useful here.  If I write a
template like this:
<HTML>
  <HEAD>
    <TITLE>
      $title
    </TITLE>
  </HEAD>
  <BODY #if ($bgcolor)
          BGCOLOR="$bgcolor"
        #end
  >
    schmoo, schmoo, schmoo
    #if ($a)
      $object.method()
    #end
  </BODY>
</HTML>

And call it with a context that has
$title == "Test page", $bgcolor == "#FFFFFF",
$a = true and $object.method() == "result"

then I expect Velocity to produce the following HTML:
<HTML>
  <HEAD>
    <TITLE>
      Test page
    </TITLE>
  </HEAD>
  <BODY
          BGCOLOR="#FFFFFF"

  >
    schmoo, schmoo, schmoo

      result

  </BODY>
</HTML>

This is fine.  That's Velocity's job.  What I want now is another
tool that sits between Velocity and the user and converts the
above HTML into the following (equivalent) HTML:
<HTML><HEAD><TITLE>Test page</TITLE></HEAD><BODY
BGCOLOR="#FFFFFF">schmoo, schmoo, schmoo result</BODY></HTML>

This is a separate process from the whole Velocity template
system -- I would actually love to have this work for static (non
Velocity) HTML as well.  In an extreme example that actually
happened I have been able to reduce a static HTML file from
~130KB to ~35KB using this technique.

Thinking about this more, maybe I should be looking for an Apache
module that does this instead...

So as far as I can tell it's not a Velocity issue, but does
anyone know of a tool that will do this and that plays nice with
Velocity?

Thanks.  I'll shut up now.

Richard Neish

----- Original Message -----
From: "Dan Finkelstein" <da...@emind.com>
To: <ve...@jakarta.apache.org>
Sent: Wednesday, July 25, 2001 12:31 PM
Subject: Re: VTL question


> I've been following the whitespace discussion for a while and
wanted to put
> my two cents in:
>
> I think that whitespace handling is part of the processing
cycle, as
> templates are processed, our job is to provide directives on
how we wish
> the output to look.  I think of the template system as a
processing pass,
> and controlling any and all output is important.
>
> Also, I don't think a "post-processing" filter is sufficient to
do that job
> -- it would be very complex and remove control that a
processing system
> should have as part of it.  It's true that a filter will "help"
and address
> my people's concern's, but I don't think of it as a generalized
solution.
>
> I suggest the addition of a directive to the velocity VTL,
which allows us
> template writers to control whitespace on a line-by-line basis.
Of course,
> we'd be able to set an overall default value.
>
> Here's how it might be used:
>
> #whitespace(compressionOn)
> #macro( altbgcolor $RowCount)
>          #if ( ($RowCount%2) == 1 )
>                  #ffffff
>          #else
>                  #d3d3d3
>          #end
> #end
> #whitespace(default)            // revert to previous setting
>
> The above directive would remove all spaces,tabs and NLs as
though the
> macro had been squeezed.
>
> In a similar way, these directives would control how whitespace
is handled
> throughout the template -- in general, I think that a
reasonable default
> will suffice, say (compressionOn) for html projects.  The
shipped with
> default could be as now, say (compressionOff).
>
> Of course, the parameters to #whitespace could be enhanced to
allow a much
> finer level of control, such as only removing spaces and tabs,
or a special
> debug mode...
>
> Just my 2 cents worth,
> Dan


Re: VTL question

Posted by Nick Bauman <ni...@cortexity.com>.
> OK Brian,
> 
> your 
> 
> #macro( getAlternateBGColor $rowCount )
> 
> is elegant and fixes it.

Agreed. I think you could stop right there, IMO. 

> 
> But Velocity should be able to control its output. The

It does.

> time will come when somebody will generate output for
> a language where whitespace and NLs make a difference,
> and he/she will have to go through this again.

True, but you can solve it with a macro. And when someone does, we will all 
hunt them down and kill them. =)

> 
> Plus, in big projects, developers are horribly busy.
> So they will have to take care of business logic AND
> presentation logic. And even if they do,
> testing/debugging a macro is way lighter than
> testing/debugging a class.

Which makes me think you are contradicting yourself here? I'm sorry, people 
have said I'm as thick as a whale omlette before, but if that's true then 
why do we need a #whitespace directive, for instance?

> So, IMHO, for Velocity to be industrial-strength, it
>should have a non-whitespace, non-NL directive, like
> ^(#fffff)
> 
> G'night
> 
> piero

And while I'm at it, I do not believe Velocity needs float support, but 
that's just me.

-- 
Nick Bauman
Software Engineer
3600 Dupont
Minneapolis, MN
55412
Mobile Phone: (612) 810-7406
Home Phone: (612) 522-0165


Re: VTL question

Posted by piero de salvia <pi...@yahoo.com>.
OK Brian,

your 

#macro( getAlternateBGColor $rowCount )

is elegant and fixes it.

But Velocity should be able to control its output. The
time will come when somebody will generate output for
a language where whitespace and NLs make a difference,
and he/she will have to go through this again.

Plus, in big projects, developers are horribly busy.
So they will have to take care of business logic AND
presentation logic. And even if they do,
testing/debugging a macro is way lighter than
testing/debugging a class.

So, IMHO, for Velocity to be industrial-strength, it
should have a non-whitespace, non-NL directive, like
^(#fffff)

G'night

piero

--- Brian Lloyd-Newberry <ne...@yahoo.com> wrote:
>    Ok... This really scares me...
> 
>    I see the ability to suppress newlines as a
> potential benefit to
> readability of the templates. As for suppression of
> all whitespace I am
> not so sure. I think it is a slippery slope that is
> going to probably
> make writing velocity templates more "complicated"
> and "messy" which in
> my opinion is bad. A directive to change parsing
> behavior at parse time
> seems nice at first thought but I am not so sure it
> will be the panacea
> that it appears to be.
> 
>    A macro that wraps a java call seems like a good
> option here. I
> would do something like:
> 
> #macro( getAlternateBGColor $rowCount )
> $UTILS.coloration.getAlternatingColor( $rowCount )
> #end
> 
.....

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

Re: VTL question

Posted by Brian Lloyd-Newberry <ne...@yahoo.com>.
   Ok... This really scares me...

   I see the ability to suppress newlines as a potential benefit to
readability of the templates. As for suppression of all whitespace I am
not so sure. I think it is a slippery slope that is going to probably
make writing velocity templates more "complicated" and "messy" which in
my opinion is bad. A directive to change parsing behavior at parse time
seems nice at first thought but I am not so sure it will be the panacea
that it appears to be.

   A macro that wraps a java call seems like a good option here. I
would do something like:

#macro( getAlternateBGColor $rowCount )
$UTILS.coloration.getAlternatingColor( $rowCount )
#end

for a more "flexible" implementation you could wrap a macro around a
method that would populate the color alternator with a list of colors
to be alternated

#macro( setBGColorAlternatives $colorList )
$UTILS.coloration.setAlternatingColors( $colorList )
#end

Then you could do a:
#setBGColorAlternatives( '#ffffff', '#d3d3d3', '#a4a4a4' )

and embed a:
#getAlternateBGColor( 5 )

This appears to be cleaner than the below snippet and avoids whitespace
concerns altogether. It does of course mean that you will have to write
Java code as opposed to velocity code and find some way to get the
UTILS stuff into the context.

> #whitespace(compressionOn)
> #macro( altbgcolor $RowCount)
>          #if ( ($RowCount%2) == 1 )
>                  #ffffff
>          #else
>                  #d3d3d3
>          #end
> #end
> #whitespace(default)            // revert to previous setting

Of course this is just my 2c (now we collectively have 4c) as a
relative newcomer that is really enjoying the Velocity experience. 

-Brian
   

--- Dan Finkelstein <da...@emind.com> wrote:
> I've been following the whitespace discussion for a while and wanted
> to put 
> my two cents in:
> 
> I think that whitespace handling is part of the processing cycle, as 
> templates are processed, our job is to provide directives on how we
> wish 
> the output to look.  I think of the template system as a processing
> pass, 
> and controlling any and all output is important.
> 
> Also, I don't think a "post-processing" filter is sufficient to do
> that job 
> -- it would be very complex and remove control that a processing
> system 
> should have as part of it.  It's true that a filter will "help" and
> address 
> my people's concern's, but I don't think of it as a generalized
> solution.
> 
> I suggest the addition of a directive to the velocity VTL, which
> allows us 
> template writers to control whitespace on a line-by-line basis.  Of
> course, 
> we'd be able to set an overall default value.
> 
> Here's how it might be used:
> 
> #whitespace(compressionOn)
> #macro( altbgcolor $RowCount)
>          #if ( ($RowCount%2) == 1 )
>                  #ffffff
>          #else
>                  #d3d3d3
>          #end
> #end
> #whitespace(default)            // revert to previous setting
> 
> The above directive would remove all spaces,tabs and NLs as though
> the 
> macro had been squeezed.
> 
> In a similar way, these directives would control how whitespace is
> handled 
> throughout the template -- in general, I think that a reasonable
> default 
> will suffice, say (compressionOn) for html projects.  The shipped
> with 
> default could be as now, say (compressionOff).
> 
> Of course, the parameters to #whitespace could be enhanced to allow a
> much 
> finer level of control, such as only removing spaces and tabs, or a
> special 
> debug mode...
> 
> Just my 2 cents worth,
> Dan
> 
> 


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

Re: VTL question

Posted by Dan Finkelstein <da...@emind.com>.
I've been following the whitespace discussion for a while and wanted to put 
my two cents in:

I think that whitespace handling is part of the processing cycle, as 
templates are processed, our job is to provide directives on how we wish 
the output to look.  I think of the template system as a processing pass, 
and controlling any and all output is important.

Also, I don't think a "post-processing" filter is sufficient to do that job 
-- it would be very complex and remove control that a processing system 
should have as part of it.  It's true that a filter will "help" and address 
my people's concern's, but I don't think of it as a generalized solution.

I suggest the addition of a directive to the velocity VTL, which allows us 
template writers to control whitespace on a line-by-line basis.  Of course, 
we'd be able to set an overall default value.

Here's how it might be used:

#whitespace(compressionOn)
#macro( altbgcolor $RowCount)
         #if ( ($RowCount%2) == 1 )
                 #ffffff
         #else
                 #d3d3d3
         #end
#end
#whitespace(default)            // revert to previous setting

The above directive would remove all spaces,tabs and NLs as though the 
macro had been squeezed.

In a similar way, these directives would control how whitespace is handled 
throughout the template -- in general, I think that a reasonable default 
will suffice, say (compressionOn) for html projects.  The shipped with 
default could be as now, say (compressionOff).

Of course, the parameters to #whitespace could be enhanced to allow a much 
finer level of control, such as only removing spaces and tabs, or a special 
debug mode...

Just my 2 cents worth,
Dan



At 10:08 AM 7/25/01 -0700, you wrote:
>Thanks to Brian and Richard for the suggestions.
>
>As usual,
>
>thinking about it, I found what seems to be the
>solution.
>
>as the old timers often suggest, 'drop a tool in the
>context'. So, I'll create a tool called Compactor,
>i'll make sure it is always in context, and i will
>
><td bgcolor="$compactor(#mymacro($velocityCount))">
>
>Now, I will comment that this is a hack to me.
>
>I was reading in an old post that since Velocity is a
>general template processor, it doesn't matter if the
>output contains whitespace, newlines and stuff like
>that.
>
>Well, being a template processor, it does matter,
>because it should provide, natively, tools to have
>exact control over its output.
>
>I do understand that things like DateFormat,
>MoneyFormat etc. belong to the context.
>
>But, the same way the silent operator, !, is
>considered something essential enough to be included
>in VTL, being able to control whitespace/newline
>outputting seems to me just as basic.
>
>we are not at a higher abstraction level than the
>silent operator.
>
>Another issue rather essential to me, brought up some
>time ago, is that you cannot break up a list with
>newlines for readability.
>
>It is really strange to me that it's not feasible,
>also given the fact that the parser is written by
>JavaCC, which is supposed to be superpowerful.
>
>We want to use Velocity for super-industrial strength
>apps, so these things appear important to me.
>
>A GIGANTIC step in this direction is VelocityEngine. I
>think that because of how democratically Velocity is
>developed, we will get there.
>
>cheers
>
>piero de salvia
>
>__________________________________________________
>Do You Yahoo!?
>Make international calls for as low as $.04/minute with Yahoo! Messenger
>http://phonecard.yahoo.com/

Dan Finkelstein
Senior Architect, Instructional Tools & Technology
eMind LLC
Northern California Annex
1250 Addison St, Suite #210
Berkeley, CA 94702-1700
Tel: (510) 486-2740
Fax: (510)486-2843

Visit us at <http://www.emind.com/>

This email message is for the sole use of the intended recipient(s) and may
contain confidential and privileged information. Any unauthorized review,
use, disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply email and destroy all copies
of the original message.


Re: VTL question

Posted by piero de salvia <pi...@yahoo.com>.
Thanks to Brian and Richard for the suggestions.

As usual,

thinking about it, I found what seems to be the
solution.

as the old timers often suggest, 'drop a tool in the
context'. So, I'll create a tool called Compactor,
i'll make sure it is always in context, and i will

<td bgcolor="$compactor(#mymacro($velocityCount))">

Now, I will comment that this is a hack to me. 

I was reading in an old post that since Velocity is a
general template processor, it doesn't matter if the
output contains whitespace, newlines and stuff like
that. 

Well, being a template processor, it does matter,
because it should provide, natively, tools to have
exact control over its output. 

I do understand that things like DateFormat,
MoneyFormat etc. belong to the context. 

But, the same way the silent operator, !, is
considered something essential enough to be included
in VTL, being able to control whitespace/newline
outputting seems to me just as basic.

we are not at a higher abstraction level than the
silent operator.

Another issue rather essential to me, brought up some
time ago, is that you cannot break up a list with
newlines for readability.

It is really strange to me that it's not feasible,
also given the fact that the parser is written by
JavaCC, which is supposed to be superpowerful.

We want to use Velocity for super-industrial strength
apps, so these things appear important to me.

A GIGANTIC step in this direction is VelocityEngine. I
think that because of how democratically Velocity is
developed, we will get there.

cheers 

piero de salvia

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

Re: VTL question

Posted by Richard Neish <ri...@rmp.com.jm>.
This is my first post to the list, so I'd like to say thanks to
the Velocity developers (Geir) for a great product.  Having said
that, I think this problem here is indicative of a problem not
with Velocity, but with the whole approach of template-driven
content in general.

We all want to make our templates easy to read and modify by
using blank spaces, indents, comments etc, but we want the
template output to be as lean as possible for quick downloads,
small file sizes, etc.  Velocity takes what I think is the right
approach and doesn't attempt this output post-processing, but I
would love to find a product that does.

So here's the question:  Does anyone know of a product that works
well with Velocity that will do this kind of output processing?
If a stable product isn't out there, I might take a stab at
writing one for my own purposes, but that would probably end up
being web-centric, at least in it's first incarnation.  I haven't
thought about it a whole lot, but I would probably subclass
VelocityServlet and put output processing code after the call to
merge().

Comments?

Thanks,

Richard Neish

----- Original Message -----
From: "piero de salvia" <pi...@yahoo.com>
To: <ve...@jakarta.apache.org>
Sent: Wednesday, July 25, 2001 10:10 AM
Subject: VTL question


> Hi all,
>
> I was trying to implement the ever present altbgcolor
> macro, to make my table rows white and grey, so i
> wrote this:
>
> #macro( altbgcolor $RowCount)
> #if ( ($RowCount%2) == 1 )
> #ffffff
> #else
> #d3d3d3
> #end
> #end
>
> and I called it from a loop as
> #altbgcolor(velocityCount)
>
> surprise!
> a nice /n is output after the color, and, after having
> gone through the archives, it seems to me that my only
> choice is this:
> #macro( altbgcolor $RowCount)
> #if ( ($RowCount%2) == 1 ) #ffffff #else #d3d3d3 #end
> #end
>
> rather ugly, plus if the macro is complicated, this is
> tantamount to writing it in bytecode...
>
> how did you guys do (or hack)  it ?
>
> piero de salvia
>
> __________________________________________________
> Do You Yahoo!?
> Make international calls for as low as $.04/minute with Yahoo!
Messenger
> http://phonecard.yahoo.com/
>


Re: VTL question

Posted by Christoph Reck <Ch...@dlr.de>.
The whitespace is an issue I have been addressing since
early ages of Velocity. I've been doing a lot of hacks
to have nice VTL and nice output, e.g.:

#macro( altbgcolor $RowCount)#*
  *##if ( ($RowCount%2) == 1 )#*
    *##ffffff#*
  *##else#*
    *##d3d3d3#*
  *##end##
#end

or even

#macro( altbgcolor $RowCount)##
#*  *##if ( ($RowCount%2) == 1 )##
#*    *##ffffff##
#*  *##else##
#*    *##d3d3d3##
#*  *##end##
#end

Which really look yucky but work fine.

I'm strongly against a #whitespace directive (Nick - and also support 
of floats! - just use $number.getFloat("123.456") ).

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
The simple solution is to update velocity to just ignore leading/trailing
whitespaces for standalone directives.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

The *big* gain is that line oriented output (as is HTML, SQL, XML, etc...)
can be easily encapsulated by indented VTL.

Sorry, but even then the above macro would not change much, since you're
trywing to output a word. It would gain a wee little:
#macro( altbgcolor $RowCount)
  #if( ($RowCount%2) == 1 )
#*  *##d3d3d3##
  #else 
#*  *##d3d3d3##
  #end
#end

See my other mails on whitespace handling proposal for advantages 
and drawbacks of the propesed enhancement.

:) Christoph


piero de salvia wrote:
> 
> Hi all,
> 
> I was trying to implement the ever present altbgcolor
> macro, to make my table rows white and grey, so i
> wrote this:
> 
> #macro( altbgcolor $RowCount)
>         #if ( ($RowCount%2) == 1 )
>                 #ffffff
>         #else
>                 #d3d3d3
>         #end
> #end
> 
> and I called it from a loop as
> #altbgcolor(velocityCount)
> 
> surprise!
> a nice /n is output after the color, and, after having
> gone through the archives, it seems to me that my only
> choice is this:
> #macro( altbgcolor $RowCount)
> #if ( ($RowCount%2) == 1 ) #ffffff #else #d3d3d3 #end
> #end
> 
> rather ugly, plus if the macro is complicated, this is
> tantamount to writing it in bytecode...
> 
> how did you guys do (or hack)  it ?
> 
> piero de salvia

Velocity mini case study

Posted by Nick Bauman <ni...@cortexity.com>.
I just wanted to share my findings on Velocity. I use velocity as an
embedded mail templating system in our application server.

When I began this subproject, I was using JSP as the language for generating
template output for our application server. It was horrible. There were many
problems, not to mention the difficulty of embedding a servlet engine in the
app server that I could communicate with through direct method calls instead
of over a socket. Specific to the Velocity argument was the JSP template
versus the VTL template. I'd like to show you what my JSP template looked
like. Package names have been changed to protect the innocent. Here is an
example:

----------------8<---------------

<%@ page session="false"
        import="java.util.*,
        foo.events.*,
        foo.emeeting.*,
        foo.validation.*,
        foo.util.actionevent.ActionEvent,
        java.util.Date"%>

<jsp:useBean id="meeting" scope="request" type="foo.IMeeting"
class="foo.Meeting"/>

<html>

<!-- etc -->

<table width="600" border="0" cellspacing="0" cellpadding="4" bgcolor="white">
<tr>
<td>
<%
Iterator            events = meeting.getStoredEventsIterator();
int                 repId = 0;

%>
<i><b>Topic: <%= meeting.getTopic()%></b></i>
<p>
<%
while (events.hasNext()) {
  Object event = events.next();
  Participation yapper =
meeting.getParticipation(((MeetingEvent)event).getFromId());
  if(event instanceof ChatEvent) {
    if("R".equals(yapper.getRole()) ) {
%>
<font color="#000000"><b><%=yapper.getName()%>:</b></font>
<%
      repId = yapper.getParticipantId();
    } else {
%>
<font color="#0000f0"><b><%=yapper.getName()%>:</b></font>
<%
    }
    ChatEvent ce = (ChatEvent) event;
%>
<br>
<%
  } else if(event instanceof URLPushedEvent) {
    if("R".equals(yapper.getRole()) ) {
%>
<font color="#000000"><b><%=yapper.getName()%>:</b></font>
<%
    } else {
%>
<font color="#0000f0"><b><%=yapper.getName()%>:</b></font>
<%
    }
    URLPushedEvent pe = (URLPushedEvent) event;
%>
<a href="<%=pe.getStoredData()%>">"<%=pe.getStoredData()%>"</a> <br>
<%
  }
}
%>
<hr>
<br><%=meeting.getMeetingId()%>:<%=repId%><br>
</td>
</tr>
</table>
</div>
</body>
</html>

----------------8<---------------

Seasick yet? Now here is the Velocity template accomplishing the same thing
as above:

----------------8<---------------

<html>

<!-- etc -->

<table width="600" border="0" cellspacing="0" cellpadding="4" bgcolor="white">
<tr>
<td>
<i><b>Topic: $meeting.getTopic()</b></i><p>

#foreach( $event in $meeting.getStoredEventsIterator() )
  #set( $yapper = $meeting.getParticipation($event.getFromId()) )
  #if( $event.getClass().getName().equals($urlEvent) )
    #if( $repRole.equals($yapper.getRole()) )
      #set( $repId = $yapper.getParticipantId() )
      <font color="$blk"><b>$yapper.getName()</b></font>
    #else
      <font color="$blu"><b>$yapper.getName()</b></font>
    #end
    <a href="$event.getStoredData()">$event.getStoredData()</a> <br>
  #elseif( $event.getClass().getName().equals($chatEvent) )
    #if($repRole.equals($yapper.getRole()) )
      #set( $repId = $yapper.getParticipantId() )
      <font color="$blk"><b>$yapper.getName()</b></font>
    #else
      <font color="$blu"><b>$yapper.getName()</b></font>
    #end
    $event.getStoredData() <br>
  #end
#end
<hr>
<br>$meeting.getMeetingId():$repId<br>
</td>
</tr>
</table>
</div>
</body>
</html>

----------------8<---------------

I was subsequently able to define that largish foreach loop into a macro and
shrink it even more, using Velocity's #macro function, so I could do this:

#drawStandardHtmlTranscript ( $meeting )

removing 20 lines of code from each template whilst only adding 2 lines (one
for #parse and the other for the #drawStandardHtmlTranscript.

The call to the Velocity runtime to finally merge the template consumes
about 20-50 milleseconds (on a 400 mHz PII Linux system) when I pool the
contexts (time doubles when I do not). This is great performance, too!

Last but not least, teaching the web design team to write a template took
literally 10 minutes from start to finish. They haven't asked me a single
question since.

-- 
Nick Bauman
Software Engineer
3600 Dupont
Minneapolis, MN
55412
Mobile Phone: (612) 810-7406
Home Phone: (612) 522-0165


Re: VTL question

Posted by Brian Lloyd-Newberry <ne...@yahoo.com>.
Piero,

  I have velocity like that all over my code generator. It sure would
be nice to be able to swallow end of lines like you can in C with a /
as the last character (before the newline or /r/n or /r). I had
considered the idea of adding a directive bt that seemed hackish... For
now things just end up looking a little ugly on the template side to
make things look nice on the generated code side.

-Brian

--- piero de salvia <pi...@yahoo.com> wrote:
> Hi all,
> 
> I was trying to implement the ever present altbgcolor
> macro, to make my table rows white and grey, so i
> wrote this:
> 
> #macro( altbgcolor $RowCount)
> 	#if ( ($RowCount%2) == 1 )
> 		#ffffff
> 	#else
> 		#d3d3d3
> 	#end
> #end
> 
> and I called it from a loop as 
> #altbgcolor(velocityCount)
> 
> surprise!
> a nice /n is output after the color, and, after having
> gone through the archives, it seems to me that my only
> choice is this:
> #macro( altbgcolor $RowCount)
> #if ( ($RowCount%2) == 1 ) #ffffff #else #d3d3d3 #end
> #end
> 
> rather ugly, plus if the macro is complicated, this is
> tantamount to writing it in bytecode...
> 
> how did you guys do (or hack)  it ?
> 
> piero de salvia
> 
> __________________________________________________
> Do You Yahoo!?
> Make international calls for as low as $.04/minute with Yahoo!
> Messenger
> http://phonecard.yahoo.com/


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/