[WM] Figuring out the order of processing.
Robert Echlin
rechlin at magma.ca
Fri Apr 30 15:43:51 IST 2004
Hi, jlm,
I think most opportunities for self-referential links occur in
navigation bars.
You might find interesting the nav bar sample I provided in a
(multiply-sent) message called duplicate code.
As I mentioned in that message, there is code duplicated between the
sitemapnode and sitemapleaf functions, so the code is not ideal, but it
eliminates self-referential links in a nav bar.
Robert
jlm17 wrote:
> I'm new to using webmake, and I am trying to create a new tag, <nsrlink>
> (a non-self-referential link). Useability experts say that web pages
> shouldn't have links in them to themselves. I want to follow this
> advice, so I want to be able to do something like this:
>
> <nsrlink href="index.html">Home</nsrlink>
>
> instead of:
>
> <a href="index.html">Home</a>
>
> and know that if the tag was placed into the index.html file it would
> not be a link, but if it was placed in any other file it would be.
>
> Ok, so here is my perl function for doing this:
>
> sub nsrlink
> {
> my $tag=shift(@_);
> return("") if($tag ne "nsrlink");
> my $attributes=shift(@_);
> my $text=shift(@_);
> my $this=get_current_main_content();
> my $url=get_url($this.".html");
> my $href=${$attributes}{"href"};
> $href=expand($href);
> if($url eq $href) { return($text); }
> else { return("<a href=\"$href\">".$text."</a>"); }
> }
>
> The key problem is with that get_current_main_content() function.
> According to the documentation that function is only guarenteed to be
> valid if called from within a deferred content reference. I'm about at
> my wits end trying to get a deferred content reference to then execute
> some perl code.
>
> My idea was to have the function called by the custom tag <nsrlink> to
> write out something like:
> <{set foo="<{perl nsrlink(\"nsrlink\", { \"href\" => \"index.html\" },
> \"dud\");}\>"}> $[foo]
>
> I also tried <wmmeta> instead of <{set}>
>
> Then the evaluation of $[foo] would be deferred, it resolves to a perl
> block which is then executed. I can't get this to work. First off,
> inside the perl block I have quotes. How do I escape them, since quotes
> delimit the foo="..." stuff? Also It seems that I can't have the '>' in
> my perl block either, as that makes webmake unable to parse. What I have
> been doing is backslashing all of these things, but I'm not certian if
> this is the correct direction to go in.
>
> Right now this works:
> <{set dud="<{perl nsrlink("nsrlink", { "href" => "index.htm" },
> "dud");}>"}> $[dud]
> But I can't get a perl block to output that text.
>
> I hope I am explaining this clearly. I think what I need is when webmake
> sees this:
> <nsrlink href="index.html">dud</nsrlink>
> It calls a function which outputs this:
> <{set foo="<{perl nsrlink("nsrlink", { "href" => "index.htm" },
> "dud");}>"}> $[foo]
> And when $[foo] is evaluated get_current_main_content() is valid and
> nsrlink returns the html that I want it to return.
>
> Is this even possible? I see that the navtree plugin requires that it be
> added to the html as a deferred content reference.
>
> Thanks for your time.
> _______________________________________________
> Webmake-talk mailing list
> Webmake-talk at taint.org
> http://webmake.taint.org/mailman/listinfo/webmake-talk
>
--
Robert Echlin
rechlin [at] magma.CA
Personal site: "Some People's Parents" => magma.ca/~rechlin
Company site: OfficeProfessor.CA
More information about the Webmake-talk
mailing list