Site templates often contain page-specific code. Tools like
DreamWeaver don't deal with this well (eventually they'' need
design-time conditionals, but they aren't there yet). Embperl deals
with it fine, but....
As an example, a page might have a navigation element that appeared as
Home
on the front page, and
<a href="/index.html">Home</a>
on all other pages.
I can think of two ways of handling that in Embperl, although there are others
[$ if (PageIs('/index.html')) $]
Home
[$ else $]
<a href="/index.html">Home</a>
[$ endif $]
or
[- ShowLink('Home', '/index.html') -]
In the former case PageIs checks the SCRIPT_NAME environment
variable, special cases index.html and / as the same, and returns the
appropriate value. In the second case we define a [$ sub $]
somewhere that does the right thing.
Note that that was the simple case, consider the following:
<tr>
<td><img name="home" border="0"
src="/images/nav_on_home.gif" width="122" height="24"
alt="MeAIMH Home">
</td>
</tr>
and
<tr>
<td><a href="/index.html" onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('home','',
'/images/nav_on_home.gif',1)">
<img name="home" border="0" src="/images/nav_off_homes.gif"
width="122" height="25" alt="MeAIMH Home"></a>
</td>
</tr>
Here's the problem regardless of the complexity. The first Embperl
example is going to show up in a program like DreamWeaver as
EPTAG Home EPTAG <a href="/index.html">Home</a> EPTAG
which will completely blow out the design and make it very hard for
the designer to figure out what things look like. (That assumes
you've installed my DreamWeaver extensions for marking Embperl tags,
otherwise it looks even worse.) The second example is no better, it
shows up as EPTAG, giving the designer no clue what it's going to
look like.
Here's what I'd like to be able to do, making up some syntax on the
fly. (Including a new kind of sub declaration, but you get the idea.)
<a href="/index.html" eplsub=pagelink>Home</a>
[$ sub pagelink($tagname, $tagarray, $taghash, $tagstring,
$content, $endtag) $]
[$ if (PageIs($taghash->{href})) $]
[+ $content +]
[$ else $]
[+ $tagstring . $content . $endtag +]
[$ endif $]
[$ endsub $]
I've stolen some of these ideas from HTML::Parser. $tagname in this
case would be 'a'. $tagarray is an array of the elements in the tag
(e.g. href,eplsub) in order. $taghash is the lookup array. $content
is either empty (this is a non-enclosing tag) or contains everything
between this tag and its end tag. $tagstring is the text of the tag
with arguments, and $endtag is the terminating tag if any.
There might be a better way of specifying which tags get executed
(eplsub might upset some compliance checkers). You could use css
tags and the sub could be something like:
[$ sub a:pagelink $]
You'll note that the second example I gave isn't quite so easy.
You'd probably want to have the default be no link, and the code
would generate the HTML for the more complex roll-over case,
depending on naming conventions for the images.
Thoughts?
--
Kee Hinckley - Somewhere.Com, LLC
http://consulting.somewhere.com/
[EMAIL PROTECTED]
I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]