String/doc

This module Houses general purpose string functions for ease of use in other modules.
Template:Md

## Loading the module

To load this module, Add this line of code to the start of your module:
Template:DarkCodeBox
All methods described below will be available under the loaded table.

## Methods

All methods are available below as fields under the required object name.

NOTE: All functions described here are NOT part of the original lua string library. they are stored under this object for simplicity.

### string.ucfirst

Template:M
This method returns `<string>` with the first letter of every word to upper case.

### string.lcfirst

Template:M
This method works exactly like Template:M, but with every letter of the first word being uppercase.

### string.blankCell

Template:M
This method returns a HTML blank cell like {{blank cell}}.

### string.infoNeeded

Template:M
This method returns a info needed text like {{InfoNeeded}}.

### string.reverseSymbol

Template:M
This method returns a copy of Template:P with certain characters like **Script error: No such module "String/Templates".** or **Script error: No such module "String/Templates".** replaced with their flipped counterparts. It also reverses the returned string with Template:M if the parameter Template:P is set to true.

### string.pcall

Template:M
This method calls Template:P with the arguments as set in Template:P. If no error is raised in calling the function, all values returned by Template:P are returned. Else, it returns the error message as a template error.

### string.makeTitle

Template:M
This method returns a HTML **Script error: No such module "String/Templates".** element (Template:Tag if Template:P is set to **Script error: No such module "String/Templates".**) with the **Script error: No such module "String/Templates".** attribute set to the text of Template:P and the inner text as Template:P. If Template:P is set to **Script error: No such module "String/Templates".**, Template:P is not required (otherwise required).

### string.parseDualArg

Template:M
This method returns the value if it is a string, if it is a table, it concatenates it with Template:M with an empty string as a default parameter or the **Script error: No such module "String/Templates".** field in the provided table, if it is a number, it converts it to a string.

### string.wrapLink

Template:M
This method returns a wikilink with Template:P as the link target, and Template:P as the display text.

### string.externalUrl

Template:M
This method returns an external link to a external website provided by Template:P with Template:P as an optional URL query and optional alternate text provided by Template:P.

### string.fullUrl

Template:M
This method returns an internal URL to a page provided by Template:P with Template:P as an optional URL query and optional alternate text provided by Template:P in a similar fashion to Template:M.

### string.\_repeat

Template:M
This method takes the string in Template:P and repeats it according to the delimiter Template:P separated by the text specified in Template:P if it is omitted.

### string.wrapHtml

Template:M
Alternative Calls:

* Template:M
* Template:M

This method is provided as a light-weight alternative to Template:M. If you need to make more complex elements like tables, use Template:M.

The function returns Template:P wrapped by the html element with the tag name specified in Template:P with the attributes in Template:P if the parameter is omitted.

There are special cases for attributes:

* **Class:** - The class names for the element can be just a string, or it can be an table of classes. If the input is a table, the keys in the arrays are joined by spaces.
* **Style:** - The css rule can be just a string, or it can be a table. In the case of the attribute being a table, the attribute is a CSS rule with the table key as the CSS property name, and the value as the CSS value of the omitted property.

#### Examples

Regular example
Template:DarkCodeBox
Produces:

Foo

Table function call
Template:DarkCodeBox
Produces:

Foo

Special Attribute values
Template:DarkCodeBox
Produces:

Foo

### string.\_formatShortNum

Template:M
This method returns a short formatted version of Template:P like **Script error: No such module "String/Templates".**.

### string.\_toNumber

Template:M
This method converts a string (can be a formatted number returned by the method above) to a number using Template:M.

### string.\_formatNum

Template:M
This method converts Template:P to a formatted number using Template:M.

### string.error

Template:M
This method returns a string as a template error with Template:P and Template:P as arguments to Template:M

### string.centerText

Template:M
This method returns a **Script error: No such module "String/Templates".** element that aligns the text to the center of an element using Template:M.

### string.\_toRoman

Template:M
This method returns a copy of Template:P with numbers converted to roman numerals.

### string.\_toArabic

Template:M
This method returns a copy of Template:P with roman numerals converted to numbers. Basically it is a oposite of Template:M.

### string.\_splitNameAndTier

Template:M
This method extracts a name and tier from the target string Template:P. It returns a table with 2 values, the first being the name, the second being the tier.

### string.\_lorem

Template:M
**Script error: No such module "Color".**
This method returns a lorem sample text based on the length of Template:P.

### string.roundNumber

Template:M
This method returns Template:P rounded to the number of decimal places specified by Template:P.
Template:P defaults to 1.

### string.\_delDoubleSpace

Template:M
This method returns a copy of Template:P with all duplicate spaces removed using the following lua pattern: **Script error: No such module "String/Templates".** with the replacement being **Script error: No such module "String/Templates".**.