注意:1.4.5 的更新内容量较大,页面上很可能仍有内容尚未更新。
如中文 wiki 信息过时,可以参考英文 wiki 对应页面。
Terraria Wiki:项目/1.4.5 获取 wiki 状态与更新指南

Template:Comma

来自Terraria Wiki
跳转到导航 跳转到搜索
This template is i18n-ready, which means it is easy to localize for different languages. Please see I18n & l10n for templates to learn more.
See Template:Comma/l10n for the localization of this template.
Important.svg
CAUTION: Terraria Wiki code is complex!!!
If you want to use this code on another wiki, wiki.gg staff are not able to assist you.
Please consider picking a different wiki to adapt code from, or making your own templates!
Remember that content on a wiki is more important than fancy formatting.
Template-info.svg 文档 以下文档来自Template:Comma/doc。(编辑 | 历史

Separates strings of text with commas. It uses Oxford commas in English.

Usage

This template is a dual-style template. It can be transcluded in two different ways with the exact same output.

Single-template style

{{ comma | <text 1> | <text 2> | ... | <text n> | or = y/yes | sep1 = <custom separator> | sep2 = <custom separator> | sep3 = <custom separator> }}

Unnamed parameters

Strings of text that will be separated by commas, can be continued nearly infinitely. Empty parameters will be ignored.

or

Changes the connector word between the last two strings of text from "and" (the default) to "or".

sep1, sep2, sep3

Custom separators to override the default ones. $sep2 is the separator if there are exactly two strings of text. $sep1 is the separator between all strings of text except the last two and $sep3 is the separator between the last two strings of text.

Parameter Default Example (default) Example (__)
sep1 A、B、C、和D A__B__C、和D
sep2 A和B A__B
sep3 、和 A、B、C、和D A、B、C__D

Multi-template style

{{ comma/start | or = y/yes | sep1 = <custom separator> | sep2 = <custom separator> | sep3 = <custom separator> }}
{{ comma/item | <text 1> }}
{{ comma/item | <text 2> }}
...
{{ comma/item | <text n> }}
{{ comma/end | or = y/yes }}

See above for parameter descriptions. $or can be set either in {{comma/start}} or in {{comma/end}}, both are possible.

This multi-template style is useful when the number of strings is variable, i.e. unknown beforehand, and is often useful within the code of other templates, such as {{distinguish}}.

Examples

Code Result
{{comma|A}} A
{{comma|A|B}} A和B FAIL! (expected: A and B)
{{comma|A|B|C}} A、B、和C FAIL! (expected: A, B, and C)
{{comma|A|B|C|D}} A、B、C、和D FAIL! (expected: A, B, C, and D)
{{comma|A||C|D}} A、C、和D FAIL! (expected: A, C, and D)
{{comma|A||C|||||H}} A、C、和H FAIL! (expected: A, C, and H)
{{comma|or=y|A}} A
{{comma|or=y|A|B}} A或B FAIL! (expected: A or B)
{{comma|or=y|A|B|C}} A、B、或C FAIL! (expected: A, B, or C)
{{comma|or=y|A|B|C|D}} A、B、C、或D FAIL! (expected: A, B, C, or D)
{{comma|A|B|C|D|sep1=×|sep3=×...×}} A×B×C×...×D
{{comma|or=y|A|B|C|D|sep1=×|sep3=×...×}} A×B×C×...×D
{{comma/start}}{{comma/item|A}}{{comma/item|B}}{{comma/end}} A和B FAIL! (expected: A and B)
{{comma/start}}{{comma/item|A}}{{comma/item|B}}{{comma/item|C}}{{comma/item|D}}{{comma/end}} A、B、C、和D FAIL! (expected: A, B, C, and D)
{{comma/start|or=y}}{{comma/item|A}}{{comma/item|B}}{{comma/item|C}}{{comma/end}} A、B、或C FAIL! (expected: A, B, or C)
{{comma/start}}{{comma/item|A}}{{comma/item|B}}{{comma/item|C}}{{comma/end|or=y}} A、B、或C FAIL! (expected: A, B, or C)
{{comma/start}}{{comma/end}}
{{comma/start|sep1=×|sep3=×...×}}{{comma/item|A}}{{comma/item|B}}{{comma/item|C}}{{comma/item|D}}{{comma/end}} A×B×C×...×D
{{#af_template:comma|{{#af_list:A|B|C|D}}}} A、B、C、和D FAIL! (expected: A, B, C, and D)
{{#af_template:comma|{{#af_object:or=y|1=A|2=B|3=C|4=D}}}} A、B、C、或D FAIL! (expected: A, B, C, or D)
{{#af_template:comma|{{#af_merge:{{#af_list:A|B|C|D}}|{{#af_object:or=y}}}}}} A、B、C、或D FAIL! (expected: A, B, C, or D)

es-formal:Plantilla:Comma