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 [EMAIL PROTECTED] http://webmake.taint.org/mailman/listinfo/webmake-talk
_______________________________________________ Webmake-talk mailing list [EMAIL PROTECTED] http://webmake.taint.org/mailman/listinfo/webmake-talk