Template:Category/Guide/edge

From Miniscope
Jump to: navigation, search

Row template for the workflow graph in Template:Category/Guide. Invoked once per workflow-node row by Template:Category/Guide/workflow_diagram via #ask with format=template, named args=yes, link=none, mainlabel=Page, and ?Has prerequisite guide=Prereqs.

Named args:

  • Page — the workflow node (a guide page, a direct child of the workflow root).
  • Prereqs — comma-separated list of prerequisite guides for this Page,
 or empty when this node has no prerequisites. SMW joins multi-values with
 ", "; #arraymap accepts that as a multi-char
 delimiter directly.

Emits, per row:

  1. A mermaid node declaration page_slug["page label"].
  2. One edge per prerequisite: prereq_slug["prereq label"] --> page_slug["page label"].
  3. A click handler — exactly one per workflow node.

Why g0 for slugs

Mermaid IDs must be alphanumeric + underscore — no spaces, slashes, dots, or other special characters. The natural way to slugify a page name is chained #replace, but that does not work inside an SMW format=template row template: nested sub-templates get transcluded as raw text and ParserFunctions inside them never fire (see Template:Category/Dashboard/sub_dashboard_card's noinclude for the same warning). Magic words DO evaluate in this context.

Page would be the obvious magic-word choice — but it only strips the path when the namespace has subpages enabled ($wgNamespacesWithSubpages), which is off by default in NS_MAIN. On a wiki without main-namespace subpages, Guide/Prepare_animal returns Guide/Prepare_animal — slash intact — and mermaid rejects the slash.

0 sidesteps the issue: it returns the page's numeric database ID (e.g., 3052), which is guaranteed unique per page and contains only digits. Prefixed with a letter (g here, for "guide") it becomes g3052 — a valid mermaid ID regardless of the page's title or namespace config.

Caveat: 0 returns the empty string if the page does not exist. For workflow members this is a non-issue because SMW only returns pages that exist (the Has parent guide filter excludes redlinks). For prerequisites pointing to non-existent pages, the slug would be just g and the edge would collide with any other broken reference — easy to spot but worth knowing.