Helps with site navigation: outputs a sequence of <a href=".."> .. </a>
or
<outerhtmltag ..><a href=".."> .. </a></outerhtmltag>
in a uniform manner.
|X|hax.htmlLinks:myTag:outerhtmltag: ..
directive in a
*.haxproj file,
attr
, itemsFirst
, itemsLast
, wrapHref
{X|myTag: items = [..] , attr = [..] |}
This topic is in a compact format for users already familiar with the essentials of declaring X-tags and invoking them. If found challenging, try the more-elaborate-and-introductory topics first to form a better grasp on the basics and overall mechanisms.
Early or Page — this X-renderer determines dynamically (documented further below) whether or not it requires a page context for rendering, so depending on each hax.htmlLinks-invoking X-tag's configuration and/or parameters:
To demonstrate valid *.haxproj directives declaring hax.htmlLinks X-tags:
|X|hax.htmlLinks:mysidenav:li |X|hax.htmlLinks:mytopnav:div: attr= [ ("class","my-nav") , ("&class","my-nav-sel") ], itemsFirst =[ ("","Home") ], itemsLast = [("blog/","{T|myBlog|}")], wrapHref = ("/" , "index.html")
To elaborate, for example the last one of the above, as all |X| directives declaring X-tags do:
|X|
followed by the X-renderer identifier (here hax.htmlLinks
) :
colon and the desired X-tag name to be used to invoke it (here mytopnav
), :
colon and now hax.htmlLinks-specific configuration:<a>
element :
colon if an optional syntax-sensitive properties block follows,
comprised (if present at all) of all the following properties in this very order:attr = [("name","value") , ..]
— the output outer-tag's markup attributes as name-value pairs
&
ampersand are only output (without it, of course) for path-wise
"current/selected/active" links with respect to the current page-context (see below paragraph for the approximate logic used
here) &
attribute names switches this X-tag's stage
from Early (the default) into Page.itemsFirst = [("uri","text") , ..]
— the links to always render firstitemsLast = [("uri","text") , ..]
— the links to always render lastwrapHref = ("","")
— the prefix-to-prepend & suffix-to-append to every rendered <a>
element's href
attribute valueFor example, {X|mysidenav: items=[("foo","Foo"),("bar","Bar")] , attr=[("class","my-foo")] |}
to output:
<li class="my-foo"><a href="foo">Foo</a></li> <li class="my-foo"><a href="bar">Bar</a></li>
For example, {X|mytopnav|}
to render in all generated /blog/*
output files:
<div class="my-nav"><a href="/index.html">Home</a></div> <div class="my-nav my-nav-sel"><a href="/blog/index.html">My Blog</a></div>
— whereas all others would see the same, minus the my-nav-sel
appendum.
No HTML/XML/etc.-escaping of inputs is performed, provide correct values for the intended output format.