velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Bubna <nbu...@gmail.com>
Subject Re: How to output a tab from a velocity template?
Date Thu, 15 Dec 2005 01:22:41 GMT
On 12/14/05, Bryce Nesbitt <bryce1@obviously.com> wrote:
> I'm using a velocity/xwork/WebWork template to write a text file, which
> needs to have tabs between each record:
>
> $res.setHeader("content-type", "text/plain")#*
> *#$res.setHeader("Content-Disposition", "attachment; filename=xxxxx.tsv")
> #foreach( $step in $result )
> RECORD&tab;$!step.PrimaryContact.firstName&tab;$!step.PrimaryContact.lastName
> #end
>
> How can I get tabs or other special characters out of Velocity? \t does
> not work.  &tab; and &#09; won't work, because the target is not a HTML
> browser.
>
> Putting actual tabs in the text file might work, but that's icky.

if actual tabs aren't icky in the output, then i don't see why they're
icky in the input.  Velocity doesn't do anything special for or with
tab characters.  if you want a tab character in the output, the
simplest thing is to put it in the input.  but if you really don't
like that, you can always put a string containing just a tab in the
context:

context.put("tab", "\t");

and then use

${tab} in your template.

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

---------------------------------------------------------------------
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