[prev in list] [next in list] [prev in thread] [next in thread] 

List:       velocity-user
Subject:    AW: Stop Template Rendering
From:       "Peter Romianowski" <megapero () gmx ! de>
Date:       2002-07-24 11:55:49
[Download RAW message or body]

Hi,

I will try 1.3.1-rc1 to see if my whole application (doing a lot of
things
with this neat thing called velocity :) is working. BTW is the bug
dealing 
with literal long and double values fixed?

I have a velocity-page that contains of a lot of distinct #if-statements
in the style of:

#if ($email)
    #if ($email.startsWith("pero")
        print something and exit
        #stop
    #end
    #if
        ...
    #end
#end

#if ($firstname))
    #if ($firstname = "Peter")
        print some text and exit
        #stop
    #end
#end

So the rendering should stop if one of the (many) nested conditions is
true. Note that I cannot use a #elseif-Statement here. My workaround
would
be to doing something like:

#set ($finished = true)

instead of the #stop-thing and then continue like this:

#if (!$finished && $firstname)
...

That would work, but there would be a lot more code processed than
needed.
I would not like to split this, because the conditions should be
readable and
understandable.

So, if you have a nicer idea, I would love to hear it. Otherwise I could
live
with the $finished-thing.

Thanks for your reply!

Peter

> Hi there,
> 
> I am using Velocity 1.2 (waiting for 1.3.1 to upgrade finally, keep on

> the good job!) and have to find a possibility to stop rendering from 
> within the

Can you try 1.3.1-rc1 to verify it's ok?

> template. First I thought #stop would do the trick, but something like

> this does not work
> 
> #if (...)
>   some text
>   #stop
> #elseif (...)
>   and so on
> #end
> 
> I think the #stop macro is not used to stop rendering but to stop 
> parsing the template. So what can I do to stop rendering from within 
> the template?
> 

Stop doesn't work.  Why do you want to stop?  Depending on that answer,
maybe you factor your templates into pieces, and then assemble
conditionally?



-- 
Geir Magnusson Jr. 
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic