الگو:Enum/Item/توضیحات

از ویکی‌پدیا، دانشنامهٔ آزاد

Outputs the first parameter, followed by a comma if both the second and third parameters are present, or " and " if only the second parameter is present. This is useful in constructing lists so that each item can be output with the appropriate separator ready for the next item in the list.

Optionally, arbitrary text can be output if neither second nor third parameters are specified, that is, if the item is the last in the list. This is useful for adding terminal punctuation such as a full stop, without the need to do decide at a higher level template whether the item is the last.

This is an implementation template intended to be used by other templates; in an article, it is easier simply to write out the list longhand, but in a template this can be complicated if the number of items in the list is unknown.

An alternative way of constructing such a list is to output the separator before each next item in the list, but that still requires knowledge of whether another item is to follow (to decide between the comma and " and ", so the two implementations boil down to the same thing.

روش استفاده[ویرایش]

{{Enum/Item|نخستین|دومین|سومین}}

پارامترهای ترتیبی همان آیتم‌های فهرستی هستند که باید نمایش داده شود. این پارامترها می‌توانند خالی باشند: به این صورت که پارامترهای ترتیبی نانوشته (که جایشان موجود ولی مقدارشان تهی باشد)، همچون پارامترهایی با مقدار خالی انگاشته می‌شوند.


پارامترهای شناخته (دارای نام) عبارتند از:

پسین: نوشتاری که پس از آیتم پایانی می‌آید. برای نمونه، می‌تواند یک «نقطه‌ویرگول» یا «نقطه» باشد. به طور پیش‌فرض مقدارش خالی است.
و: نوشتاری که می‌تواند به جای مقدار پیش‌فرض « و » به کار برده شود.
کاما: جداکننده همه آیتم‌ها به جز آیتم پایانی و پیش از پایان. مقدار پیش‌فرضش «، » (ویرگول فارسی و فاصله) می‌باشد.

نمونه‌ها[ویرایش]

The test cases include a fuller set of examples.

Input Output
{{Enum/Item|Tom}} Tom
{{Enum/Item|Tom|Dick}} Tom و
{{Enum/Item|Tom|Dick|Harry}} Tom،
{{Enum/Item|Tom|Dick|Harry|after=.|and=+}}
{{Enum/Item|Dick|Harry||after=.|and=+}}
{{Enum/Item|Harry|||after=.|and=+}}
Tom، Dick و Harry

This last example shows the intended use, where several invocations of the template, each shifted by one parameter, can be used to construct a list.

جستارهای وابسته[ویرایش]