⚠ NOTICE

The game has been released in Early Access on 26th of April, 2024.
Please keep in mind that any information provided on this Wiki may be incomplete or subject to change as the game progresses.

Template:CheckLinkText: Difference between revisions

From Manor Lords Official Wiki
(basic functionality and doc)
 
(→‎Advanced: spaces)
 
(One intermediate revision by the same user not shown)
Line 4: Line 4:
     |  
     |  
     }}</onlyinclude><noinclude>
     }}</onlyinclude><noinclude>
__NOTOC__
==Documentation==
==Documentation==
Usage intended for other templates only. It can be used to more safely add linktext if it is possible that the input might be blank (which may break stuff by making the link invisible). It will check first to see if the input is blank, and only then decide whether it should add the pipe to change the linktext.
Usage intended within other templates only, as a nested template. This template can be used to more safely add linktext if it is possible that the input might be blank (which may break stuff by making the link invisible). It will check first to see if the input is blank, and only then decide whether it should add the pipe to change the linktext. Finally it will add the input it recieved as the linktext.


As usage, put in only one unnamed parameter.
==Usage==
To use this template in another template, format the link like this, where articlearticle is the link target: <code><nowiki>[[articlearticle{{CheckLinkText| {{{parameter name|}}} }}]]</nowiki></code>


Test cases:
===Advanced===
Put in a string to check; when doing so, this template (CheckLinkText) itself accepts only one unnamed parameter. But when using this in another template, the input string given to CheckLinkText should keep it should keep its parameter markup from the main template. Ensure that the parameter's default is empty. So for example, use it as: <code><nowiki>[[Manor_Lords_Official_Wiki{{CheckLinkText|{{{parameter name|}}} }}]]</nowiki></code> where <code><nowiki>{{{parameter name|}}}</nowiki></code> is the parameter it is checking for link text, and the <code><nowiki>|}}}</nowiki></code> at the end means it defaults to an empty string.
 
You can put spaces before it; that's fine, whitespace in the link target is ignored. Don't add spaces between the ''end'' of its template brackets and the link brackets because those may be interpreted literally as part of the link text. If you need to do so for readability, add HTML comment/note tags (even if it is 7 characters long): <code><nowiki><!-- --></nowiki></code>
 
===Example===
<pre>
[[Manor Lords Official Wiki{{CheckLinkText|{{{parameter name|defaultparameterresult}}} }}]]
[[Manor Lords Official Wiki{{CheckLinkText|I want this link to look cool}}]]
</pre>
 
:[[Manor_Lords_Official_Wiki{{CheckLinkText|{{{parameter name|defaultparameterresult}}} }}]]
:[[Manor_Lords_Official_Wiki{{CheckLinkText|I want this link to look cool}}]]
 
==test cases for development use==
<pre>
{{CheckLinkText}}
{{CheckLinkText}}
{{CheckLinkText|Anchorage, Alaska}}
{{CheckLinkText|Anchorage, Alaska}} (not within a full link, so this is just what is returned to the main template)
[[Manor Lords Official Wiki{{CheckLinkText|}}]] (empty)
[[Manor Lords Official Wiki{{CheckLinkText|{{{2|}}} }}]] (main numbered parameter, default to empty)
[[Manor Lords Official Wiki{{CheckLinkText|{{{parameter name|}}} }}]] (main named parameter, default to empty)
[[Manor Lords Official Wiki{{CheckLinkText|Iwantthis link to look cool}}]] (input, should successfully rename link)
</pre>
 
:{{CheckLinkText}}
:{{CheckLinkText|Anchorage, Alaska}}
:[[Manor_Lords_Official_Wiki{{CheckLinkText|}}]]
:[[Manor_Lords_Official_Wiki{{CheckLinkText|{{{2|}}} }}]]
:[[Manor_Lords_Official_Wiki{{CheckLinkText|{{{parameter name|}}} }}]]
:[[Manor_Lords_Official_Wiki{{CheckLinkText|Iwantthis link to look cool}}]]
</noinclude>
</noinclude>

Latest revision as of 05:00, 9 May 2024


Documentation

Usage intended within other templates only, as a nested template. This template can be used to more safely add linktext if it is possible that the input might be blank (which may break stuff by making the link invisible). It will check first to see if the input is blank, and only then decide whether it should add the pipe to change the linktext. Finally it will add the input it recieved as the linktext.

Usage

To use this template in another template, format the link like this, where articlearticle is the link target: [[articlearticle{{CheckLinkText| {{{parameter name|}}} }}]]

Advanced

Put in a string to check; when doing so, this template (CheckLinkText) itself accepts only one unnamed parameter. But when using this in another template, the input string given to CheckLinkText should keep it should keep its parameter markup from the main template. Ensure that the parameter's default is empty. So for example, use it as: [[Manor_Lords_Official_Wiki{{CheckLinkText|{{{parameter name|}}} }}]] where {{{parameter name|}}} is the parameter it is checking for link text, and the |}}} at the end means it defaults to an empty string.

You can put spaces before it; that's fine, whitespace in the link target is ignored. Don't add spaces between the end of its template brackets and the link brackets because those may be interpreted literally as part of the link text. If you need to do so for readability, add HTML comment/note tags (even if it is 7 characters long): <!-- -->

Example

[[Manor Lords Official Wiki{{CheckLinkText|{{{parameter name|defaultparameterresult}}} }}]]
[[Manor Lords Official Wiki{{CheckLinkText|I want this link to look cool}}]]
defaultparameterresult
I want this link to look cool

test cases for development use

{{CheckLinkText}}
{{CheckLinkText|Anchorage, Alaska}} (not within a full link, so this is just what is returned to the main template)
[[Manor Lords Official Wiki{{CheckLinkText|}}]] (empty)
[[Manor Lords Official Wiki{{CheckLinkText|{{{2|}}} }}]] (main numbered parameter, default to empty)
[[Manor Lords Official Wiki{{CheckLinkText|{{{parameter name|}}} }}]] (main named parameter, default to empty)
[[Manor Lords Official Wiki{{CheckLinkText|Iwantthis link to look cool}}]] (input, should successfully rename link)
| Anchorage, Alaska
Manor_Lords_Official_Wiki
Manor_Lords_Official_Wiki
Manor_Lords_Official_Wiki
Iwantthis link to look cool