From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.svg

Release status:Extension status unmaintained

ImplementationTemplate:Extension#type Extended syntax, Parser extension, Tag
DescriptionTemplate:Extension#description Adds an interpreted language to MediaWiki
Author(s)Template:Extension#username Swiftly Tilting (Frantiktalk)
Latest versionTemplate:Extension#version 2.2.1 (03:58, 27 September 2010 (UTC))
MediaWikiTemplate:Extension#mediawiki 1.5+ (tested and working on 1.15.1)
LicenseTemplate:Extension#license GNU General Public License 2.0 only
Download Winter.2.2.1.zip
  • $wgWinterNamespaces
  • $wgWinterMaxNesting
  • $wgWinterMaxOperations
  • $wgWinterMaxIterations
  • $wgWinterNotAllowed
* <winterprewiki>
  • <nowinter>
Hooks usedTemplate:Extension#hook

Translate the Winter extension if it is available at translatewiki.net

Check usage and version matrix.

Winter (Wiki Interpreter) is an extension which adds an interpreted language to MediaWiki pages. It is intended to enhance the templating system but can be used on any page.

Note: While Winter can be installed along-side parser function extensions without issues, intertwining code from the two systems may have unexpected results. Please check the documentation for details.


Features of the Winter language include:

  • Simple syntax
  • Alphanumeric variables & arrays
  • if-then-else conditional statement
  • for and while conditional loops
  • User definable functions (in Winter and PHP)
  • Basic arithmetic
  • String manipulation

Try out Winter[edit]

You are welcome to test out Winter in the Sandbox area.


Quick Installation[edit]

  1. Place Winter.php in your wiki's extensions directory.
  2. Add require_once("extensions/Winter.php"); to the bottom of LocalSettings.php
  3. You're done!


Extensive documentation is available.


Example 1[edit]

This example demonstrates the use of defined functions, for loops, and variable assignment

{{#function | foo || " foobar{{#1}} " }}

{{#for | {{#a = 1}} || {{#a <=  5}} || {{#a ++}} ||
.{{#foo | {{#a}} }}.                                                                                        

Will return

. foobar1 .. foobar2 .. foobar3 .. foobar4 .. foobar5 .

Example 2[edit]

Template parameters can be accessed easily

{{#if| {{{1}}} || First parameter is set to:{{{1}}} || First parameter not set }}

Using the code above in a template will return First parameter is set to:param1 if the template is called with a first parameter set to param1 (eg [[Template:xyz|param1]]). If the first parameter is blank or not used, the template would return nothing.

Example 3 - 99 Bottles of Beer on the Wall[edit]

{{#function | formatNum ||
   {{#if | {{#1}} || {{#1}} || no more }} bottle{{#if | {{#1 == 1}} || || s}}

{{#for | {{#i @= 99}} || {{#i >= 0}} || {{#i --}} ||  
   {{#bottles | @= | {{#formatNum | {{#i}} }} }}
   {{#ucfirst | {{#bottles}} }} of beer on the wall, {{#bottles}} of beer.<br />
   {{#if | {{#i}} ||
      Take one down and pass it around, {{#formatNum| {{#i - 1}} }}
      Go to the store and buy some more, 99 bottles
   }} of beer on the wall.<br /><br />

Example 4 - Creating a Calendar[edit]

This example is too large to include on this page.

View Example 4

Release History & Change Log[edit]


  • added ^o and ^c escape characters
  • added + to allowed characters in function names and functions
  • added #reset_all_vars function
  • added ++ and -- functions
  • fixed bug with #strpos and #substr returning false when it shouldn't
  • added #is_numeric, #is_int and #is_string functions
  • fixed bug with array assignment
  • other minor bug fixes


  • added #include and #include_raw functions
  • fixed bug with long template content introduced in 2.1.1
  • fixed NOTICE of missing variables (some server configs don't supply SCRIPT_URL or SCRIPT_URI)


  • fixed NOTICE of undefined variable
  • fixed count command which would return the incorrect value


  • changed syntax so that carriage returns are ignored if followed by a space
  • added template variable access
  • added time, microtime, date, urlencode, explode, implode, request_var, template_var, to_str, to_int, show_page_text, version, wordwrap, keep_nl
  • added ^. escape char
  • added tag which allows winter to be used before mediawiki processes it
  • added addVar for external user functions to add variables
  • added WinterBeforeProcess and WinterAfterProcess hooks
  • added various information available at runtime such as user name, page name, etc
  • fixed bug with nowinter tag
  • fixed bug when using foreach with noexistent array
  • fixed bugs with & and ? operators (they’re turned into html entities)
  • fixed bug caused by pipes being returned in error messages
  • updated error messages


  • Fixed allow_call_time_pass_reference bug
  • Fixed bug with <nowinter> tag
  • Fixed bug when undefined variables were referenced
  • Added alternative comment syntax


  • Fixed some bugs with #eval
  • Changed the | (bitwise or) operator to ? since | is a reserved symbol in Winter
  • Improved #comment so that it does not evaluate code
  • Improved the escape character system


  • fixed bug in operation count which severely under counted operations
  • fixed bug when trying to loop inside of a function
  • improved #if so that it does not evaluate all parameters unnecessarily
  • improved <nowinter> tag
  • improved error messages
  • deprecated #define in favor of #str_replace_all
  • deprecated #default in favor of #set_param_default
  • added ability to nest control structures
  • added installation settings $wgWinterMaxNesting, $wgWinterMaxOperations, $wgWinterMaxIterations, $wgWinterNotAllowed
  • added external function definition support
  • added charachters - and $ to acceptable function and variable name characters, also explicitly defined _
  • added @ (silence) modifier for variable assignment operators
  • added <- and <=> variable assignment operators
  • added & | xor << >> bitwise operators
  • added ^ arithmetic operator
  • added #add, #subtract, #multiply, #divide arithmetic functions
  • added #strtoupper, #strtolower, #ucfirst, #trim, #ltrim, #rtrim, #strip_tags string functions
  • added #comment as another name for #null
  • added #debug for easy debugging stub display
  • added #rand function
  • added #html_to_xml and #xml_xpath xml function
  • added array variable type (2 dimensions maximum)
  • added #foreach loop construct for traversing arrays
  • added []= and [][]= operators for array assignment
  • added #count, #array_rand, #array_rand_value, #sort, #rsort, #asort, #arsort, #natsort, #ksort, #krsort array functions


  • Added new shortcut syntax: {{#command param1 param2 ... paramN}} is the same as {{#command| #param1 | #param2 | ... | paramN }}. Each span of whitespace is converted to a pipe character. This is especially useful for math operations: {{#op 1 + 1}} = {{#op| 1 | +| 1}}
  • #op can now accept any amount of operations. However, the order of operations is only left to right. ie {{#op 2 - 2 * 3}} will return 0 and not 4.
  • Added #formula command
  • Added #eval command
  • Added #repeat command
  • fixed some bugs in #strpos


  • <nowinter> tag added to replace #noeval command


  • Added #noeval command to allow Winter code to be displayed without being evaluated.
  • Reworked escape character code. Escape characters are now only translated inside of a Winter command instead of anywhere on the page. This ensures that users who are unaware Winter is installed are not confused.
  • #define actually works now.
  • Switched to x.y.z version numbering system.


  • Fixed problems with certain commands inside of a for loop. Also fixed the problem with newlines in variable values.
  • Added mod (modulus) operator.


  • Introduced new shortcut syntax for variables:
    {{#a}} and {{#var|a}} are now equivalent, as are {{#a|+|1}} and {{#var|a|+|1}} (an all other operators), assuming a has already been defined by a #setvar or #var command.


  • Fixed a few bugs
    • Nesting didn't always work right depending on syntax
    •  != didn't work


  • Original Public release

Updates by RSS[edit]

Winter updates are published on my blog.

RSS Feed

User feedback desired[edit]

Please feel free to submit feedback either on the talk pages here on mediawiki.org or leave a comment on my blog. You may also find my email address inside the Winter.php file. Questions, comments, bug reports, example code, etc are all welcome. I'm also interested to know for what purpose you are using Winter; let me know your site name and I'll give you a shout out on my blog.

See also[edit]


Other languages:Project:Language policy English  • 日本語