Template talk:G

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Item separation

[edit]

Normally templates get their parameters separated with pipes "|"; but for galleries the file names
are traditionally separated by linefeeds. This template accepts both separation methods,
everybody may use the own preferred method of arranging the input items.
Each existing <gallery>...</gallery> coding can be replaced by {{G|...}} without necessity to change anything else.

Technical view

There can be an unlimited number of unnamed parameters p1 to pz;
each one eof these unnamed parameter pn can have the structure that it
consists of m linefeed-separated items: (pn= is represented by the nth pipe)
G ┃ itemn1

itemn2
⠄ ⠄ ⠄
itemnm
Optical view

This structure can as well be seen in another view, that each linefeed-separated line consists of 1 to n pipe-separated items:
G ┃ itema1 | itema2 | ⠄ ⠄ ⠄ | iteman

itemb1 | itemb2 | itemb3
⠄ ⠄ ⠄
itemx1 | itemx2 | ⠄ ⠄ ⠄ ⠄ ⠄ ⠄ | itemxm
Parsing

However the input parameters are organized, with linefeeds or pipes or a mixture of both,
for the program (template, module) it does not matter - finally will be a series of all items:
itema1 – itema2 – ⠄ ⠄ – iteman - itemb1 – itemb2 – itemb3 - ⠄ ⠄ - itemx1 – itemx2 – ⠄ ⠄ – itemxm
As the program does, first all pipe-separated input is convered to strings; when there are linefeed-separations, then these strings are divided into the items.

In the special case of format=2 the obvious arrangement may be for the best overview how the names are assigned to the files:
G ┃

file1 | name1
file2 | name2 WWWWWWWWWWWWWWWWWWWWWWWW for this arrangement, format=2 will be defaulted
⠄ ⠄ ⠄
filen | namen

The program builds first the strings: file1, name1 file2, name2 ..., ... filen, namen.
The second separation breaks the strings into items at the linefeeds: file1, name1, file2, name2, ..., ..., filen, namen.
Finally all the items will be grouped to tupels: file1 - name1, file2 - name2, ... - ..., filen - namen,
because format=2 is valid – whether specified explicitely, or as the default.


When for a filen a namen should be missing it can be shown with an empty namen (a pipe followed by nothing);
this pipe is not necessary because it is checked whether some text, or the next file name follows a file name:
missing caption text is substituted by the file name (as-it-is, only understrokes are replaced by spaces).
Because of that, caption text must not look like a valid file name, i.e. end with dot + valid extension.
Repeating the file name itself does not disturb but is normally useless (except e.g. changes into lower/upper case).

When a valid file name should be used as a caption, different possibilities exist to avoid its treatment as the next file name, e.g.:
   ■ enclosing it into {{F|...}} brackets, either to use it as a link, or with the {{F}} 'nolink' option n
   ■ enclosing it into <nowiki> brackets; or adding a single <nowiki/> tag


-- 사랑16:27, 14 October 2019 (UTC)[reply]


[edit]

When called like this:

{{G|Glaskugel_--_2022_--_9832.jpg|t=small}}

this template wraps the entire gallery in small tags, which produces invalid HTML. ‎<small>...‎</small> can wrap only in-line content, and galleries are block content. Please adjust I have adjusted this template so that it does not accept in-line formatting as a wrapper for gallery tags. Jonesey95 (talk) 06:19, 27 October 2022 (UTC)[reply]