(I've just been catching up on a few months of archived aolserver-list
emails, so forgive me for awakening a sleeping thread.)
Folks are welcome to use my simple-templating system which contains
registered ADP tags to do conditional blocks of HTML, and the ability
to loop over lists of ns_sets (fetched from the DB).
Docs and downloads at http://www.oakroad.net/simple-templates/
Examples:
<if "$variable" eq "fred">
This is included if the variable is fred.
</if>
in a .tcl file:
set dbresults [template_query $db "
select rownum, user_id, email
from users
order by email
"]
in associated .html file:
<loop list=dbresults>
<tr>
<td><var rownum></td>
<td><var user_id></td>
<td><var email></td>
</tr>
</loop>
This stuff is my simplified version of the old ACS templating system
written by Karl Goldstein at aD, but should work on (just about) any
aolServer with fancy ADP parsing enabled.
On Tue, Apr 10, 2001 at 11:41:18AM -0700, ricard helene wrote:
> Maybe this isn't good coding or whatever, but normally
> I do something like this:
>
> <%
> if {$condition} {
> set html [subst {hello i like to eat death}]
> } else {
> set html [subst {hello i don't like to eat death}]
> }
>
> # other code
> ns_puts $html
> %>
>
> It makes it somewhat easier to separate code from
> display, but there are much better ways to do that
> anyway...
>
> -derek
>
> --- Alex Harvey <[EMAIL PROTECTED]> wrote:
> > Is it possible to conditionally include HTML within
> > an ADP?
> >
> > Something like this is possible in ASP, PHP or JSP
> > but I can't seem to get it to work correctly in my
> > ADP.
> >
> > <%
> > if {condition} {
> > %>
> > some HTML
> > <%
> > }
> > else {
> > %>
> > some different HTML
> > <%
> > }
> > # more script again
> > %>
> >
> > If something like this is not possible, then what is
> > the best possible way to render large amounts of
> > conditional HTML? Is there some other feature to
> > TCL/ADP that I'm overlooking?
> >
> > Thanks,
> >
> > Alex Harvey
>
>
> =====
> "Are you going to spend the rest of your life selling sugar water, or are you going
>to come with me and change the world?"
>
> __________________________________________________
> Do You Yahoo!?
> Get email at your own domain with Yahoo! Mail.
> http://personal.mail.yahoo.com/
--
Patrick Kelly -- http://www.oakroad.net/patrick.html