v50 Steam/Premium information for editors
  • v50 information can now be added to pages in the main namespace. v0.47 information can still be found in the DF2014 namespace. See here for more details on the new versioning policy.
  • Use this page to report any issues related to the migration.
This notice may be cached—the current version can be found here.

Editing Help:Parser functions

Jump to navigation Jump to search

Warning: You are not logged in.
Your IP address will be recorded in this page's edit history.


The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
{{ambox|type=orange|text=This page is not yet complete!}}
+
==Custom parser functions==
= Custom parser functions =
 
== String functions ==
 
 
 
=== char ===
 
Returns a [[CP437]] character.
 
 
 
Example: <pre>{{#char:1}}</pre>
 
&rarr; {{#char:1}}
 
 
 
 
=== strc ===
 
=== strc ===
  
Expands backslash escape sequences, such as:
+
Example: <pre></pre>
 
+
&rarr;
{|class="wikitable"
 
! Text !! Produces
 
|-
 
| \n || newline
 
|-
 
| \t || tab
 
|}
 
 
 
Example: <pre>Some example{{#strc:\t}}text</pre>
 
Produces:
 
{{#tag:pre|Some example{{#strc:\t}}text}}
 
  
 
=== strcount ===
 
=== strcount ===
  
Returns the number of occurrences of the second parameter in the first parameter. Case-sensitive
+
Example: <pre></pre>
 
+
&rarr;  
Example: <pre>{{#strcount:This string sure has a lot of "T"'s in it! | t}}</pre>
 
&rarr; {{#strcount:This string sure has a lot of "T"'s in it! | t}}
 
  
 
=== stricount ===
 
=== stricount ===
  
Same as strcount, but case-insensitive.
+
Example: <pre></pre>
 
+
&rarr;  
Example: <pre>{{#stricount:This string sure has a lot of "T"'s in it! | t}}</pre>
 
&rarr; {{#stricount:This string sure has a lot of "T"'s in it! | t}}
 
  
 
=== stripos ===
 
=== stripos ===
Line 81: Line 57:
 
=== sha1 ===
 
=== sha1 ===
  
Returns the [[wikipedia:sha1|sha1]] hash of the first parameter.
+
Example: <pre></pre>
 
+
&rarr;  
Example: <pre>{{#sha1:Dwarf Fortress}}</pre>
 
&rarr; {{#sha1:Dwarf Fortress}}
 
  
 
=== md5 ===
 
=== md5 ===
  
Returns the [[wikipedia:md5|md5]] hash of the first parameter.
+
Example: <pre></pre>
 
+
&rarr;  
Example: <pre>{{#md5:Dwarf Fortress}}</pre>
 
&rarr; {{#md5:Dwarf Fortress}}
 
 
 
=== splitrand ===
 
Splits a string and returns a random piece
 
 
 
Example: [[Main Page/Quote]]
 
 
 
== Math functions ==
 
  
 
=== randint ===
 
=== randint ===
  
Returns a random integer between the two arguments provided.
+
Example: <pre></pre>
 
+
&rarr;  
Example: <pre>{{#randint:1|6}}</pre>
 
&rarr; {{#randint:1|6}}
 
 
 
<pre>{{#randint:6|1}}</pre>
 
&rarr; {{#randint:6|1}}
 
  
 
=== ordinal ===
 
<pre>{{#ordinal:1}}</pre>
 
&rarr; {{#ordinal:1}}
 
 
== Wikitext/utility functions ==
 
 
=== colorconvert ===
 
Converts a color from one format to another.
 
 
Usage:
 
{{<nowiki/>#colorconvert: ''color'' | ''from_format'' | ''to_format'' }}
 
 
See {{tl|color scheme}} for an example.
 
 
Supported formats:
 
{| class="wikitable pre-table"
 
|-
 
! format
 
! example
 
! result
 
|-
 
| <pre>rgb</pre>
 
| <pre>{{#colorconvert:rgb(255,128,12)|rgb|hex}}</pre>
 
| {{#tag:pre|{{#colorconvert:rgb(255,128,12)|rgb|hex}}}}
 
|-
 
| <pre>hex</pre>
 
| <pre>{{#colorconvert:#ff800c|hex|rgb}}</pre>
 
| {{#tag:pre|{{#colorconvert:#ff800c|hex|rgb}}}}
 
|-
 
| <pre>rgb1</pre>*
 
| <pre>{{#colorconvert:rgb(255,128,12)|rgb|rgb1}}</pre>
 
| {{#tag:pre|{{#colorconvert:rgb(255,128,12)|rgb|rgb1}}}}
 
|-
 
| <pre>rgb2</pre>*
 
| <pre>{{#colorconvert:rgb(255,128,12)|rgb|rgb2}}</pre>
 
| {{#tag:pre|{{#colorconvert:rgb(255,128,12)|rgb|rgb2}}}}
 
|-
 
| <pre>rgb3</pre>*
 
| <pre>{{#colorconvert:rgb(255,128,12)|rgb|rgb3}}</pre>
 
| {{#tag:pre|{{#colorconvert:rgb(255,128,12)|rgb|rgb3}}}}
 
|}
 
<nowiki/><small>*These can only be used as the third argument</small>
 
 
=== param ===
 
=== param ===
  
For use in templates: Returns the first parameter found from a list of parameter names, or the last argument if none were found. Intended to be easier to read than a chain of template default arguments. The following lines are equivalent:
+
Example: <pre></pre>
<pre>
+
&rarr;
{{{first|{{{2|{{{1|{{{last|None of the parameters were found}}}}}}}}}}}}
 
{{#param:first|2|1|last|None of the parameters were found}}
 
</pre>
 
 
 
Example:  
 
 
 
"Template:Sample" contains: <pre>{{#param:first|2|1|last|None of the parameters were found}}</pre>
 
----
 
<pre>{{sample|first=text}}</pre>
 
&rarr; text
 
----
 
<pre>{{sample|text}}</pre>
 
&rarr; text
 
----
 
<pre>{{sample|foo|bar}}</pre>
 
&rarr; bar
 
----
 
<pre>{{sample|a|b|last=c|first=First!}}</pre>
 
&rarr; First!
 
----
 
<pre>{{sample|3=foo}}</pre>
 
&rarr; None of the parameters were found
 

Please note that all contributions to Dwarf Fortress Wiki are considered to be released under the GFDL & MIT (see Dwarf Fortress Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, 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. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel Editing help (opens in new window)