velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Charles N. Harvey III" <charl...@alloy.com>
Subject RE: indentation of templates
Date Tue, 12 Mar 2002 15:12:56 GMT
I have noticed the formatting thing too.  Agreed, nothing is wrong with
Velocity, it works just fine.  I just wish that the #if and #end statements
didn't get "tab" all screwy.  Such as:

------ template file ------
		<table>
			<tr>
			#if ($variable)
				<td>output true stuff</td>
			#else
				<td>output false stuff</td>
			#end
			</tr>
		</table>
------ template file ------


------ output html file ------
		<table>
			<tr>
							<td>output true stuff</td>
						</tr>
		</table>
------ output html file ------

#if and #end both add 3 "tabs" to my outputted code.  Its just weird that's
all.
Its not a huge deal.  But I (and some other co-workers) are really anal
about what the output looks like.  Don't ask me why, I know it makes
absolutely
NO difference to the browser.  Just my two cents.  Sorry if I am annoying.


Charlie



> -----Original Message-----
> From: Simon Christian [mailto:simon@cpd.co.uk]
> Sent: Tuesday, March 12, 2002 4:23 AM
> To: Velocity Users List
> Subject: Re: indentation of templates
>
>
> Should the #if directive be gobbling the whitespace before it? I've
> found the same effect as you evidently have, but get around it by
> starting the #if and #else directives at the beginning of the line i.e.
>
> #if (this-is-true)
> 	output true stuff
> 	$context.applyTemplates("section")
> #else
> 	output false stuff
> 	#execute_a_macro()
> #end
>
> I agree wholeheartedly with you on the desired output formatting, just
> not sure that anything has gone *wrong* in Velocity in this case.
>
> - s
>
>
> Bill Burton wrote:
>
> > Hi Sebastien,
> >
> > Glad to hear you like Velocity.
> >
> > I have recently run into the same extra whitespace issue while
> working on
> > a DVSL stylesheet.  The #if directive never seems to gobble up leading
> > whitespace even if it's the only thing on the line.  Whereas the #set
> > directive does do this.
> >
> > What I did to allow indentation of directives while eliminating
> the extra
> > whitespace is to use multiline comments to hide whitespace.  If these
> > comments are used before #if, #else, #elseif and matching #end's as well
> > as before invoking other tools or macros, you can get the output to be
> > indented properly.  Here's an example:
> >
> > #*       *##if (this-is-true)
> >            output true stuff
> > #*         *#$context.applyTemplates("section")
> > #*       *##else
> >            output false stuff
> > #*         *##execute_a_macro()
> > #*       *##end
> >
> > Even though the above looks odd, I like it much better than putting
> > everything flush left.
> >
> > The only thing is once in a while, I've forgotten the # before the
> > directive and put *#else instead of *##else.
> >
> > If you need to eliminate blank lines, start the #* at the end
> of the prior
> > line to comment out the enclosed newline.
> >
> > -Bill
> >
>
>
>
> --
> To unsubscribe, e-mail:
> <mailto:velocity-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:velocity-user-help@jakarta.apache.org>
>


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