|
7.3 Replacing Messy HTML Constructs One of the greatest benefits of using FunnelWeb is its ability to replace messy slabs of HTML with a simple macro call. This page provides lots of examples of this.
Hyperlinks are messy and you can eliminate their messiness from your FunnelWeb web source by defining a macro for each link you want to use. For example:
@$@<Dilbert@>@Z@M@{@- <A HREF="http://www.dilbert.com/">Dilbert</A>@} @$@<Yahoo@>@Z@M@{@- <A HREF="http://www.yahoo.com/">Yahoo</A>@} While the definitions themselves are certainly messy, having made them, we are now free to refer to Dilbert and Yahoo within our webs in a very clean manner indeed. For example, the links page of the previous example now becomes just:
@O@<links.html@>@{ @<Begin page@>@(Dave's Links@) <P>Check out @<Dilbert@> and @<Yahoo@>! @<End page@> @}
Suppose we want to include a small image of a checkmark at various points without a web page. Here's the HTML that has to be included at each point:
<IMG SRC="bin/tick_red_12.gif" WIDTH="12" HEIGHT="12" HSPACE=4 VSPACE=0 ALT="*" BORDER="0"> Yuk! To eliminate this mess in our FunnelWeb/HTML, we can define a macro for a tick mark as follows:
@$@<Tick@>@M@{ <IMG SRC="bin/tick_red_12.gif" WIDTH="12" HEIGHT="12" HSPACE=4 VSPACE=0 ALT="*" BORDER="0">@} Now, using tick marks without your text is easy. Here's an example:
@<Tick@>Low cost.<BR> @<Tick@>Easy installation.<BR> @<Tick@>Available now!<BR>
Another example is where you have form fields with lots of options. Here's an example of a commonly occurring form field that goes on for a couple of hundred lines!
<SELECT NAME="Country"> <OPTION>United States <OPTION>Afghanistan <OPTION>Albania ... <OPTION>Zambia <OPTION>Zimbabwe </SELECT> Using FunnelWeb, you can move all this to a single macro definition as follows:
@$@<Country form field@>@M@( <SELECT NAME="Country"> <OPTION>United States <OPTION>Afghanistan <OPTION>Albania ... <OPTION>Zambia <OPTION>Zimbabwe </SELECT> Now, whenever you want a country field in a form, you can just write:
@<Country form field@>
Sometimes the navigation constructs that appear within pages can become rather messy. Here's an example where we have three buttons at the bottom of each page.
<TABLE WIDTH="100%"> <TR> <TD ALIGN="left" VALIGN="bottom">< A HREF="links.html"><IMG SRC="bin/left.gif"></A></TD> <TD ALIGN="center" VALIGN="bottom">< A HREF="home.html"><IMG SRC="bin/up.gif"></A></TD> <TD ALIGN="right" VALIGN="bottom">< A HREF="hobbies.html">< IMG SRC="bin/right.gif"></A></TD> </TR> </TABLE> We can move all this to a single macro definition that has three parameters, one for each target page.
@$@<Nav@>@(@3@)@Z@M@{ @<P@> <TABLE WIDTH="100%"> <TR> <TD ALIGN="left" VALIGN="bottom">< A HREF="@1"><IMG SRC="bin/left.gif"></A></TD> <TD ALIGN="center" VALIGN="bottom">< A HREF="@2"><IMG SRC="bin/up.gif"></A></TD> <TD ALIGN="right" VALIGN="bottom">< A HREF="@3"><IMG SRC="bin/right.gif"></A></TD> </TR> </TABLE> @} Now, to add navigation buttons to a page, we can just write (near the end of the page).
@<Nav@>@(links.html@,home.html@,hobbies.html@) If you wanted to, you could build the navigation buttons into the @<End page@> macro and set it up with three parameters instead.
Webmaster Copyright © Ross N. Williams 1992,1999. All rights reserved. |