Editing
Template talk:IfEmpty
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
Since wiki.rpg.new does not support the #if statement, this template provides "if like" functionality using a trick in the template engine. To utilize this template, type: <nowiki>{{IfEmpty|{{{NameOfKey}}}=text that should appear when NameOfKey is empty|text that should appear when NameOfKey has a value}}</nowiki> This logic works because IfEmpty outputs a single parameter, which is the empty string. If it is not present, then it outputs the first non-named parameter. The trick is that we pass through the ''value'' of the key that we want to analyze as a named parameter. So when the key has an empty value, you get: {| |- |=text that should appear when NameOfKey is empty |- |1=text that should appear when NameOfKey has a value |} Because the empty string key is present, 'text that should appear when NameOfKey is empty' is outputted. However, if NameOfKey has a value, then IfEmpty is called with: {| |- |the value stored in NameOfKey=text that should appear when NameOfKey is empty |- |1=text that should appear when NameOfKey has a value |} Because the empty string key is now missing, we output 'text that should appear when NameOfKey has a value'. The only further trick is that every key used this way must be ''defined'' in the template. If it's not present, then the trick doesn't work. So just define every key, but leave the ones that you aren't using blank, and IfEmpty will work well.
Summary:
Please note that all contributions to RPGnet may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
RPGnet:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Template
Discussion
English
Views
Read
Edit
Add topic
View history
More
Search
Navigation
RPGnet
Main Page
Major Projects
Categories
Recent changes
Random page
Help
Tools
What links here
Related changes
Special pages
Page information