velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergiu Dumitriu <ser...@xwiki.com>
Subject Re: Directive indenting ?
Date Mon, 21 Mar 2011 18:50:55 GMT
On 03/21/2011 07:04 PM, Rich Wagner wrote:
>
> Sorry in advance if this is a FAQ whose answer I haven't found...
>
> Instead of writing:
>
>
> #foreach( $container in $Containers )
> #if( $container.prop("Generate") )
>      ...stuff...
> #end
> #end
>
>
> I'd like to indent the "#if" and its "#end", for the sake of better readability:
>
>
> #foreach( $container in $Containers )
>      #if( $container.prop("Generate") )
>      ...stuff...
>      #end
> #end
>
>
> But then I find the spaces before the "#if" and its matching "#end" show up in the output,
which I don't want to happen.
>
> To get around this, I've implemented a somewhat hack-ish Template preprocesser:  my resource
loader wraps a template's stream inside my own stream implementation which filters template
lines.  That is, if a line starts with "<white-space>#blah", the initial spaces are
trimmed off.
>
> That works, and isn't all that intrusive.  But if "off-the-shelf" Velocity already provides
an easier way to accomplish the same thing, I'd prefer that...

No, there's no similar feature directly in Velocity yet.

-- 
Sergiu Dumitriu
http://purl.org/net/sergiu/

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


Mime
View raw message