Difference between revisions of "Template:FindYDCportal/doc"
imported>BrownHairedGirl (tweak) |
imported>BrownHairedGirl (→Usage: clarify) |
||
| Line 21: | Line 21: | ||
== Usage == | == Usage == | ||
; Year parameter | ; Year parameter | ||
| − | <code><nowiki>{{FindYDCportal|YYYY}}</nowiki></code> | + | <code><nowiki>{{FindYDCportal|YYYY}}</nowiki></code> ... where <code><nowiki>YYYY</nowiki></code> is a 3- or 4-digit year |
; Decade parameter | ; Decade parameter | ||
| − | <code><nowiki>{{FindYDCportal|YYY0s}}</nowiki></code> | + | <code><nowiki>{{FindYDCportal|YYY0s}}</nowiki></code> ... where <code><nowiki>YYY0s</nowiki></code> is a 3- or 4-digit decade |
== Examples == | == Examples == | ||
Revision as of 23:43, 22 November 2018
| This is a documentation subpage for Template:FindYDCportal. It contains usage information, categories and other content that is not part of the original template page. |
| This template uses Lua: |
A helper template to find the most specific chronology portal for a given year
It is a wrapper template around Module:FindYDCportal. For use within templates, it is most efficient to invoke the module directly. For one-off use, the template requires less typing and makes the code easier to read.
Contents
Parameters
Takes one parameter, which must be either a year (e.g. "1879", "1123") or a decade (e.g. "1940s", "730s").
If the parameter is missing, empty, or does not fit the required format, an empty string is returned.
Output
If a portal is found, returns its name without the namespace prefix, e.g.
- for "Portal:1980s" return
1980s - for "Portal:19th century" return
19th century
If no portal is found, it returns an empty string.
Usage
- Year parameter
{{FindYDCportal|YYYY}} ... where YYYY is a 3- or 4-digit year
- Decade parameter
{{FindYDCportal|YYY0s}} ... where YYY0s is a 3- or 4-digit decade
Examples
- Years
{{FindYDCportal|2018}}→{{FindYDCportal|1935}}→{{FindYDCportal|1857}}→{{FindYDCportal|736}}→{{FindYDCportal|1800}}→
- Decades
{{FindYDCportal|2000s}}→{{FindYDCportal|1940s}}→{{FindYDCportal|560s}}→
- Missing parameter
{{FindYDCportal}}→
- Empty parameter
{{FindYDCportal|}}→
- Invalid parameter
{{FindYDCportal|1927-related}}→{{FindYDCportal|Swedish chef}}→
Logic
If the parameter is a year:
- If the year portal exists, return its name.
Otherwise try the decade. - If the decade portal exists, return its name.
Otherwise try the century - If the century portal exists, return its name.
Otherwise return an empty string
If the parameter is a decade:
- If the decade portal exists, return its name.
Otherwise try the century - If the century portal exists, return its name.
Otherwise return an empty string
See also