Parser Functions and Lua Scripts

From Training Material
Jump to navigation Jump to search

Parser and Lua⌘

  • General MediaWiki does not allow for logic to be implemented
  • Parser functions were introduced to give MediaWiki some programming like functionality

allowing you to use commands like if and exists.

  • You can define your own parser functions, and there is an extension with predefined functions that comes bundled with MediaWiki since version 1.17.
  • Unfortunately these are somewhat limited, and complex logic can become unreadable.
  • The scribunto extension is being developed, to allow use of programming languages in MediaWiki, currently only supporting the Lua Scripting language.


Parser functions⌘

http://www.mediawiki.org/wiki/Help:Extension:ParserFunctions

{{#if: 1 | yes | no}}

{{#expr: (1+4)/5}}


Lua⌘

http://www.mediawiki.org/wiki/Extension:Scribunto

Lua scripts are created in the Module namespace, Module:MyScript

to invoke a script

{{#invoke: MyScript | function | parameter1 | paremeter2 }}

http://www.mediawiki.org/wiki/Lua/Tutorial

Exercise ⌘

  • Create a Template of your cheese table.
  • include it on your cheese pages.
  • Make sure the cheeses in the table link to there related page.