模板:Rail icon
有關以下模塊的模板 |
模塊:Adjacent stations |
---|
(討論 | 沙盒 | 子頁面) |
{{Infobox station}} |
(沙盒 | 測試樣例) |
{{Station link}} |
(沙盒 | 測試樣例) |
{{Rail color}} |
(沙盒 | 測試樣例) |
{{Rail icon}} |
(沙盒 | 測試樣例) |
{{Line link}} |
(沙盒 | 測試樣例) |
{{Rail color box}} |
(沙盒 | 測試樣例) |
{{Adjacent stations}} |
(沙盒 | 測試樣例) |
本模板使用 Lua 語言: |
This template returns an icon – an image or another preset value – from a subpage of {{Adjacent stations}}.
Usage
編輯Module:Adjacent stations/system
must exist for this template to work. system is the name of the system or an abbreviation; line is the line name, if any; and type is the name of the branch or service, if any.
For example, {{ric|MTR}}
returns package.lua第80行Lua錯誤:module 'Module:Adjacent stations/港鐵' not found using Module:Adjacent stations/MTR.
Optional parameters:
|size=
– image size, expressed as width (15px
), height (x15px
) or both if necessary (15x15px
).|link=
– image link (full page name)|alt=
– alt text|bold=
– setting for some types of text-based icon; default is "yes" for all of those types
If there are two or more images by default, then the image-applicable values will be set for all of them.
Addition of values in module subpages
編輯(For simplicity, {{Rail color box}} is used here to refer to the p._box function in Module:Adjacent stations.)
Each module subpage sends a Lua table to Module:Adjacent stations. The outermost table (often the table called p
, or otherwise the table after return
. Lua tables ({ ... }
) contain keys and values, which can be in the format ["key"] = value
. Values can be strings/characters ("value"
, tables, or other values. Key–value pairs are separated by commas.
In the main (outermost) table, either or both of the keys "icon format" and "icon" can be used to specify an icon (i.e. as an entry in the table like ["icon"] = "value"
).
The value for "icon" is the standard file syntax for an inline image; there should be alt text, a page link and a size value; see Wikipedia:Extended image syntax.
If there is a value for the "icon format" key and it is not "image", then {{Rail color box}} is used, with the display style being the value of "icon format"; all inputs except "alt" and "size" are passed through appropriately. (Note that {{Rail color box}} does not currently work without a line name.)
Lines are added as tables with named keys inside the "lines" table, which is inside the main table (i.e. ... ["lines"] = {["line name"] = { ... line table ... } } ...
). Entries for "icon format" and "icon" work similarly inside these tables. If many lines have the same icon format, then a "line icon format" value can be added to the main table.
Types are added as tables inside their line tables (each type is a variation of a line). Entries for "icon format" and "icon" work similarly inside these tables. If many types have the same icon format, then a "type icon format" value can be added to the main table.
Lines and types can have aliases; these are all listed in the table with the key "aliases" inside the main table. The keys in that table should be lowercase, and the values should refer to the key of a branch or line table (e.g. ... ["aliases"] = {["r"] = "Red", ["b"] = "Blue"} ...
, where both "Red" and "Blue" are valid line or type names).
If {{Rail color box}} is used, then the key "color" and any of the keys "line title", "branch title", "short name" and "text color" should be present in the applicable table.
For an example of a subpage which works with this module, see Module:Adjacent stations/MTR.
{{ric|MTR}}
→ package.lua第80行Lua錯誤:module 'Module:Adjacent stations/港鐵' not found{{ric|MTR|Island}}
→ package.lua第80行Lua錯誤:module 'Module:Adjacent stations/港鐵' not found{{ric|MTR|ISL}}
→ package.lua第80行Lua錯誤:module 'Module:Adjacent stations/港鐵' not found (using the "isl" alias)
上述文件嵌入自Template:Rail icon/doc。 (編輯 | 歷史) 編者可以在本模板的沙盒 (建立 | 鏡像)和測試樣例 (建立)頁面進行實驗。 請在/doc子頁面中添加分類。本模板的子頁面。 |