You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Oliver Heyden <5h...@informatik.uni-hamburg.de> on 2001/01/24 15:51:13 UTC

template-indentations

Hi,

I am just new to velocity and have one question regarding templates:

When I use the following template:

public void test(){
#foreach ($name in $names)
	$name.lock();
#if ($name.isMember())
	${name}.welcome();
#else
	${name}.register();
#end
#end
}

velocity produces correctly something like

public void test(){
	Martin.lock();
	Martin.welcome();
	Susan.lock();
	Susan.welcome();
	Hans.lock();
	Hans.register();
}

My problem is, that the template does not look very clear because of the
missing indentations before the vtl-statements.
I'd rather use something like the following template with indentations
before the vtl-statements in order to make the template more readable:

public void test(){
#foreach ($name in $names)
	$name.lock();
    #if ($name.isMember())
	${name}.welcome();
    #else
	${name}.register();
    #end
#end
}

But then velocity writes all the indentation-spaces in the output, so
that I get:

public void test(){
	Martin.lock();
            Martin.welcome();
	Susan.lock();
	    Susan.welcome();
	Hans.lock();
	    Hans.register();
}

Is there any way to make indentations before vtl-statements in a
template without velocity writing it in the output??

By the way, is there a mailing-archive??

Thank you in advance.

Ciao, Olli

Re: template-indentations

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Oliver Heyden wrote:
> 
> Hi,
> 
> I am just new to velocity and have one question regarding templates:
> 
> When I use the following template:
> 
> public void test(){
> #foreach ($name in $names)
>         $name.lock();
> #if ($name.isMember())
>         ${name}.welcome();
> #else
>         ${name}.register();
> #end
> #end
> }
> 
> velocity produces correctly something like
> 
> public void test(){
>         Martin.lock();
>         Martin.welcome();
>         Susan.lock();
>         Susan.welcome();
>         Hans.lock();
>         Hans.register();
> }
> 
> My problem is, that the template does not look very clear because of the
> missing indentations before the vtl-statements.
> I'd rather use something like the following template with indentations
> before the vtl-statements in order to make the template more readable:
> 
> public void test(){
> #foreach ($name in $names)
>         $name.lock();
>     #if ($name.isMember())
>         ${name}.welcome();
>     #else
>         ${name}.register();
>     #end
> #end
> }
> 
> But then velocity writes all the indentation-spaces in the output, so
> that I get:
> 
> public void test(){
>         Martin.lock();
>             Martin.welcome();
>         Susan.lock();
>             Susan.welcome();
>         Hans.lock();
>             Hans.register();
> }
> 
> Is there any way to make indentations before vtl-statements in a
> template without velocity writing it in the output??

Right now, no.  The reason is that since Velocity is a general purpose
template engine, we want to be as accurate as possible when reproducing
the non-Velocity Template Language input to the output.

This issue has been noted though. :)

> By the way, is there a mailing-archive??

http://www.mail-archive.com/velocity-dev%40jakarta.apache.org/
http://www.mail-archive.com/velocity-user%40jakarta.apache.org/

> Thank you in advance.
> 
> Ciao, Olli

-- 
Geir Magnusson Jr.                               geirm@optonline.com
Velocity : it's not just a good idea. It should be the law.
http://jakarta.apache.org/velocity