Help:Sabr parser functions

From SABR Encyclopedia

Jump to: navigation, search

This help page covers a variety of unrelated parser functions grouped together in a single file that provide small, but essential, functionality in the Encyclopedia.

Contents

sabr-lightbox-link

{{#sabr-lightbox-link}} is a custom parser function written by SABR staffer Peter Garver to generate links to pop up lightboxes in the Encyclopedia. It is a very simple parser function that takes one to four parameters and generates an anchor (A) tag in raw html.

Purpose

The parser function is needed in the Encyclopedia because mediawiki does not offer a mechanism for generating anchor tags with specific class and rev attributes. Both of these are required to use floatbox, the lightbox clone currently used in the Encyclopedia.

Parameters

The parser function automatically sets the class to "floatbox", and automatically links to an anchor within whatever page it's on. The parameters specify:

  1. Which anchor the link points to
  2. The link title (visible in the tooltip when hovering over the link, and used as a caption in the lightbox) (default: 'Statistics')
  3. The "rev" attribute of the link, which holds the options to be passed to floatbox (default: 'scrolling: auto')
  4. The link text (default: 'Statistics')

Example call

Here is an example call, as it would appear in Babe Ruth's page:

{{#sabr-lightbox-link:
 stats_batting
 |Batting statistics for Babe Ruth
 |width:95%;height:95%;scrolling:auto
 |Batting Statistics}}

This call would output this HTML (line breaks added for clarity - real output contains none):

<a 
 href="#stats_batting" 
 title="Batting statistics for Babe Ruth" 
 class="floatbox" 
 rev="width:95%;height:95%;scrolling:auto"
>

Batting Statistics

</a>

This would create the following link, which will do almost nothing on this page: Batting Statistics.

Usage in the Encyclopedia

The extension is written to require options passed to floatbox to be provided as a parameter, rather than hardcoding them. This means that calls directly to the parser function are not pretty and contain information that is not related to encyclopedia content. Therefore, calls should be isolated inside of templates. The parser function is used in the following templates:

sabr-iframe-link

{{#sabr-iframe-link}} is a custom parser function written by SABR staffer Peter Garver to generate links to pop up lightboxes in the Encyclopedia. It is a very simple parser function that takes one to four parameters and generates an anchor (A) tag in raw html.

sabr-iframe-link differs from sabr-lightbox-link in that it is designed to link to an external page, while sabr-lightbox-link is designed to link to an internal anchor. That is the old difference. You can see the parser function in action (and its proper use) in Template:Sabrlinks-pictorial.

sabr-prefix-ns

{{#sabr-prefix-ns}} is a custom parser function written by SABR staffer Peter Garver to ensure that a pagename is properly prefixed with its namespace, without ever duplicating the namespace prefix. It is primarily intended to be used inside templates, for images. The table below demonstrates its usage. The default namespace, as you can see below, is File:.

The parser function is not case sensitive. This is based on an assumption that people will type namespaces in either the technically correct form ("File") or the other allowable form ("file"). If someone types it in a specifically incorrect form (e.g. "FILE"), this function can't fix it.

Also note that output for the last example in the table is probably not what you would want in any circumstance, so remember that the parser function is not very intelligent, and try not to push it too hard.

Template contents Rendered output
{{#sabr-prefix-ns:Chone Figgins.jpg}} File:Chone Figgins.jpg
{{#sabr-prefix-ns:Chone Figgins.jpg|Help:}} Help:Chone Figgins.jpg
{{#sabr-prefix-ns:File:Chone Figgins.jpg}} File:Chone Figgins.jpg
{{#sabr-prefix-ns:file:Chone Figgins.jpg|File:}} file:Chone Figgins.jpg
{{#sabr-prefix-ns:Help:Chone Figgins.jpg|Help:}} Help:Chone Figgins.jpg
{{#sabr-prefix-ns:File:Chone Figgins.jpg|Help:}} Help:File:Chone Figgins.jpg
Personal tools