This is an example module that demonstrates how to access arguments. It is used in Scribunto: An Introduction.

Hello worldEdit


This function displays the text "Hello, world!". It doesn't use any arguments.


  • {{#invoke:ArgsDemo|hello_world}} → Hello, world!



This function greets the specified user. It uses one argument, name.


  • {{#invoke:ArgsDemo|hello|Fred}} → Hello, Fred!
  • {{#invoke:ArgsDemo|hello|Jane}} → Hello, Jane!



This function adds two numbers, num1 and num2.


  • {{#invoke:ArgsDemo|add|5|3}} → 8
  • {{#invoke:ArgsDemo|add|100|25}} → 125

Count fruitEdit


This function displays how many apples and how many bananas we have. It uses named arguments.


  • {{#invoke:ArgsDemo|count_fruit|bananas=5|apples=3}} → I have 5 bananas and 3 apples
  • {{#invoke:ArgsDemo|count_fruit|apples=7|bananas=4}} → I have 4 bananas and 7 apples

Has fruitEdit


Displays the number of bananas, apples and cherries a named person has. This function mixes positional arguments with optional named arguments.


  • {{#invoke:ArgsDemo|has_fruit|Fred|bananas=5|cherries=7}} → Fred has: 5 bananas 7 cherries
  • {{#invoke:ArgsDemo|has_fruit|Jane|cherries=9|apples=4}} → Jane has: 4 apples 9 cherries

Custom fruitEdit


Displays the number of items of different fruit. Any fruit can be displayed; the function is not limited to particular types of fruit as it was in previous functions. This is done by iterating over the arguments. Note that the arguments are processed in an arbitrary order.


  • {{#invoke:ArgsDemo|custom_fruit|pineapples=10|oranges=5}} → I have: 5 oranges 10 pineapples
  • {{#invoke:ArgsDemo|custom_fruit|lemons=6|grapefruits=3|bananas=4|grapes=20}} → I have: 4 bananas 6 lemons 3 grapefruits 20 grapes

Custom fruit 2Edit


Displays the number of items of different fruit that a named person has. Similarly to the custom_fruit function, this function iterates over the arguments, and so is not limited to any particular types of fruit. The difference is that the function checks that each fruit is not the first positional parameter, so that name isn't erroneously listed as a fruit.


  • {{#invoke:ArgsDemo|custom_fruit_2|Fred|pineapples=10|oranges=5}} → Fred has: 5 oranges 10 pineapples
  • {{#invoke:ArgsDemo|custom_fruit_2|Jane|lemons=6|grapefruits=3|bananas=4|grapes=20}} → Jane has: 4 bananas 6 lemons 3 grapefruits 20 grapes

See alsoEdit