Forum OpenACS Q&A: Re: break out of a multiple tag?

Collapse
Posted by Tom Jackson on

I agree that the mixing of tcl code and templating tags to get something to work is a real abuse of the templating system. I can't think of a great reason to be using 'break' after considering Don's comments that the database/tcl code should be doing this job.

The code snip provided above seems to be using some obfuscated logic to put one element on the page. I think an extra bit of tcl code, or even a database query would be a cleaner way of getting what you want, and documenting what it is you are trying to do.

But maybe there are good reasons to use 'break'. What are they? Is 'continue' in the same boat? When would it be useful? What are the benefits over using 'if'?

Collapse
Posted by tammy m on
Well,

I can share why I would like to use continue in my code (copied from above in this thread).

But (knew this was coming!) in my case, I have selected just what I need out of the database and am only wanting to break or continue so that I can pair certain of these selected widgets together in my resulting HTML table. Not because I don't want them at all! If I could break or continue in my form style, I could have a special case for just a few widgets , thus pairing them in a table row.

Anyway that aside, I can do what Tilmann suggested with the enclosing if to accomplish the effect I'm after. But it is much harder to see the logic this way. You have to find the end of the if which is just not visibly available, since the file is long. Easy to work around yes but just not as clear to anyone reading the code, IMO. But not to start a flame about minor issues, I'm quite happy with my end result:)

And actually, it turned out harder to debug too as the many if ... else's in my adp weren't paired up how I intended at first. It is just more clear to my eye to have a clear if... continue at the top of a loop instead of a not so immediately visible long if ... else (itself containing lots of if ... else conditions). Just my current situation;)