Module:Example/sandbox: Difference between revisions
Appearance
Content deleted Content added
QuickQuokka (talk | contribs) Test |
QuickQuokka (talk | contribs) Resolved |
||
Line 2: | Line 2: | ||
function p.count_fruit(frame) |
function p.count_fruit(frame) |
||
local num_bananas = tonumber(frame.args.bananas) or 0 |
|||
local num_apples = tonumber(frame.args.apples) or 0 |
|||
local conj_bananas = num_bananas == 1 and 'banana' or 'bananas' |
|||
local conj_apples = num_apples == 1 and 'apple' or 'apples' |
|||
return 'I have ' .. num_bananas .. ' ' .. conj_bananas .. ' and ' .. num_apples .. ' ' .. conj_apples |
|||
end |
end |
||
Revision as of 02:42, 29 August 2023
![]() | This is the module sandbox page for Module:Example (diff). See also the companion subpage for test cases (run). |
Description | Module. |
---|---|
Code source | Example |
Status | Unknown |
Example module.
![]() | This page is not a sandbox. It should not be used for test editing. To experiment, please use the Wikipedia sandbox, your user sandbox, or the other sandboxes. |
![]() | This page serves as a reference for demonstrations and examples only, similar to other Namespace example pages. It is not part of the main encyclopedia. |
This is example documentation for the module, used for demonstrations and the like.
Documentation
Package items
example.hello(frame)
(function)- Hello world function
- Parameter:
frame
current frame (table) - Returns: Hello world
example.hello_to(frame)
(function)- Hello world function
- Parameters:
- Returns: Hello world
example.count_fruit(frame)
(function)- Counts fruit
- Parameters:
- Returns: Number of apples and bananas
example.Name2(frame)
(function)- Name2
- Parameter:
frame
current frame (table) - Returns: Some output
See also
- Module:Sandbox: For practice/experimental/testing modules.
local p = {};
function p.count_fruit(frame)
local num_bananas = tonumber(frame.args.bananas) or 0
local num_apples = tonumber(frame.args.apples) or 0
local conj_bananas = num_bananas == 1 and 'banana' or 'bananas'
local conj_apples = num_apples == 1 and 'apple' or 'apples'
return 'I have ' .. num_bananas .. ' ' .. conj_bananas .. ' and ' .. num_apples .. ' ' .. conj_apples
end
return p