Templates

In the context of this tool, templates are the key to turning your csv data into Mediawiki pages. Do not confuse mwcsvimport templates with Mediawiki templates.

A template consists of a Title and Body. Templates can contain Mediawiki style wiki markup as well as data variables. In addition to just data variables the tool now support modifiers which are special tags for formatting your data.

Data Variables

Data variables output the data contained in the respective column of your CSV file.

Syntax: {$Column Name}

If your CSV file looks like this

First Name, Last Name, Gender
John, Doe, Male, 33
Jane, Doe, Female, 22

Then you can use the following variables in your template

{$First Name}
{$Last Name}
{$Gender}

Note: Your CSV file should have column names, the tool requires it. Also, try to stick with alpha numeric column names for the best results.

Modifiers

Modifiers are special tags that you can use in your template to surround text, variables, or a mix of the two. Modifiers are like functions that take the enclosed text as an argument and outputs the result the transformed text. Some modifiers have optional or required attributes.

Syntax: {modifier_name [attrib="value"]}Some Text{/modifier_name}

String Modifiers

{capitalize}{/capitalize}
{upper}{/upper}
{upperfirst}{/upperfirst}
{lower}{/lower}
{trim}{/trim}
{rtrim}{/rtrim}
{ltrim}{/ltrim}
{camelize}{/camelize}
{reverse}{/reverse}
{strip_tags}{/strip_tags}

Number/Date Modifiers

{number_format}{/number_format}
{ordinal}{/ordinal}
{date format=""}{/date}
{time}{/time}
{md5}{/md5}
{sha1}{/sha1}
{uuid}{/uuid}


{capitalize}{/capitalize}

Capitalizes each word in surrounded text or variable

Example:
{capitalize}some example text{/capitalize}

Output:
Some Example Text

{upper}{/upper}

Transforms surrounded text or variable to upper case

Example:
{upper}some example text{/upper}

Output:
SOME EXAMPLE TEXT

{upperfirst}{/upperfirst}

Transforms first word of surrounded text or variable to upper case

Example:
{upperfirst}some example text{/upperfirst}

Output:
Some example text

{lower}{/lower}

Transforms surrounded text or variable to lower case

Example:
{upperfirst}Some Example Text{/upperfirst}

Output:
some example text

{trim}{/trim}

Removes whitespace and \n from both ends of surrounded text or variable

Example:
Text Before{trim} Some Text {/trim}Text After

Output:
Text BeforeSome TextText After

{rtrim}{/rtrim}

Removes whitespace and \n from right of surrounded text or variable

Example:
Text Before{rtrim} Some Text {/rtrim}Text After

Output:
Text Before Some TextText After

{ltrim}{/ltrim}

Removes whitespace and \n from left of surrounded text or variable

Example:
Text Before{ltrim} Some Text {ltrim}Text After

Output:
Text BeforeSome Text Text After

{camelize}{/camelize}

Camel Case surrounded text or variable

Example:
{camelize}Some Example Text{/camelize}

Output:
SomeExampleText

{reverse}{/reverse}

Reverses order of surrounded text or variable

Example:
{reverse}Some Example Text{/reverse}

Output:
txeT elpmaxE emoS

{strip_tags}{/strip_tags}

Removes HTML Tags from surrounded text or variable

Example:
{strip_tags}Some HTML <a href="http://www.example.com">example.com</a> <b>Bold Text</b>{/strip_tags}

Output:
Some HTML example.com Bold Text

{number_format}{/number_format}

Format a number with commas and decimals. Several examples are given to illustrate the optional attributes this modifier can use.

Example:

1: {number_format}1000000{/strip_tags}
2: {number_format}436572634.46364{/number_format}
3: {number_format decimals="2"}436572634.46364{/number_format}
4: {number_format decimals="3" dec_point="#" thousands_sep="~"}436572634.46364{/number_format}

Output:

1: 1,000,000
2: 436,572,634
3: 436,572,634.46
4: 436~572~634#463

{ordinal}{/ordinal}

Append the ordinal suffix of a number, ie 2nd, 5th. Several examples are given to illustrate the optional attributes this modifier can use.

Example:

1: {ordinal}2{/ordinal}
2: {ordinal}4{/ordinal}
3: {ordinal}15{/ordinal}
3: {ordinal return="false"}6{/ordinal}

Output:

1: 2nd
2: 4th
3: 15th
4: th

{date}{/date}

Format a timestamp or date. The format attribute is required and takes the same date format string as the PHP date() function. Several examples are given to illustrate it's usage.

Example:

1: {date format="M-d-Y h:iA"}1310054343{/date} 
2: {date format="M-d-Y"}{/date}  //No date provided will use current date/time 
3: {date format="r"}{/date}      //RFC 2822 date
4: {date format="c"}{/date}      //ISO 8601 date
5: {date format="U"}{/date}      //Timestamp

Output:

1: June-16-2011 12:33AM
2: July-07-2011
3: Thu, 21 Dec 2000 16:01:07 +0200
4: 2004-02-12T15:19:21+00:00
5: 1310054343

{time}{/time}

Generate a timestamp of the current date.

Example:

{time}{/time}

Output:

1024360642

{md5}{/md5}

Computers MD5 Hash of surrounded string

Example:
{md5}Some Example Text{/md5}

Output:
2bd3b9f98f9f4666d73701099e08a325

{sha1}{/sha1}

Computers SHA1 Hash of surrounded string

Example:
{sha1}Some Example Text{/sha1}

Output:
2933a8f651eb9872250e4c86846e0d72e0e2a1f1

{uuid}{/uuid}

Generates a UUID

Example:
{uuid}{/uuid}

Output:
32e81dc0-a8b3-11e0-8264-0800200c9a66