User:Wlgrin/Sandbox/Generic/Main/Template001/doc
The At User template ({{@u}}
) is a shortcut used to help transclude user pages (typically, user templates) within other user pages belonging to the same user. As a safeguard, its behaviour depends on whether the transcluding page is itself within user space (as expected) or not, thereby avoiding the inadvertent transclusion of pages from user space into Wikipedia articles or project pages.
Usage
Basic usage
Using this template, one may replace calls such as
{{User:MeMyselfEtMoi/Template/MyTemplate|Parameter value}}
with the relatively simpler
{{{{@u|MyTemplate}}|Parameter value}}
This template only expands the name of the transcluded page, so the whole call (and any parameter that may follow) must be nested within another pair of double braces.
If the transcluding page is in the User or User talk namespace, the template called through {{@u}}
will be found in a sub-page of “User:user-name/Template/” (where user-name is derived from the name of the transcluding page). If the transcluding page is in any other namespace, the template is found normally (by default, in namespace Template).
Examples For example, if the transcluding page is “User:MeMyselfEtMoi/My current projects”, using {{{{@u|My template}}|Parameter value}}
will produce
- {{User:MeMyselfEtMoi/Template/My template|Parameter value}}
If this same call was inadvertently copied into an article (out of user space), it would instead expand to
- {{My template|Parameter value}}
Prefixing with “/”
If the template name (passed as first argument to {{@u}}
) begins with a “/” and the transcluding page is in user space, the template is searched in a sub-page of “User:user-name” (instead of “User:user-name/Template/”).
Examples For example, {{{{@u|/Sandbox/My new template}}|Parameter value}}
will produce
- {{User:MeMyselfEtMoi/Sandbox/My new template|Parameter value}}
If this same call was inadvertently copied into an article (out of user space), the leading “/” would be stripped and the call would expand to
- {{Sandbox/My new template|Parameter value}}
Using substitution
This template can be safely substituted as it uses the “safesubst” modifier to call parser functions and magic words and it does not call any other template.
Caveats
If you do not need to pass any parameter, remember to separate the two closing sets of double braces; otherwise, the closing series of four braces will confuse the MediaWiki parser. For example, you can use as separator a space or a pipe. Using a pipe will cause an empty unnamed parameter to be passed to the template, which is generally without adverse consequences (but check the syntax of the called template to confirm this).
Examples For example, this incorrect call: {{{{@u|My template}}}}
will produce the likely unwanted output
- {My template}
By contrast,
{{{{@u|My template}} }}
will produce, as desired,
- {{User:MeMyselfEtMoi/Template/My template}}
Similarly, using a pipe,
{{{{@u|My template}}|}}
will produce
- {{User:MeMyselfEtMoi/Template/My template|}}
Automated processing
Since there are no valid reasons for this template to appear outside user space, an automatic script (bot) could be written to detect and strip it from non-user pages. Using substitution is the best option to do this. Otherwise, the call itself may be munged, leaving only the name of the transcluded page in its place ({{@u|Abc}} becoming Abc) and taking care of stripping any leading “/” ({{@u|/Abc}} becoming Abc).