Module:Module sandbox: Difference between revisions
Content deleted Content added
No edit summary Tags: Mobile edit Mobile web edit Advanced mobile edit |
No edit summary Tags: Reverted Mobile edit Mobile web edit Advanced mobile edit |
||
Line 12: | Line 12: | ||
if args.image then |
if args.image then |
||
output = output .. '| style="text-align: center;" | [[File:' .. args.image .. '|thumb|upright=1.5|' .. (args.imagecaption or "") .. ']]\n|-\n' |
local imageSize = args.imagesize or "150px" -- Default image size |
||
output = output .. '| style="text-align: center;" | [[File:' .. args.image .. '|thumb|upright=1.5|' .. (args.imagecaption or "") .. '|' .. imageSize .. ']]\n|-\n' |
|||
end |
end |
||
for key, value in pairs(args) do |
for key, value in pairs(args) do |
||
if type(key) == 'string' and key ~= 'description' and key ~= 'image' and key ~= 'imagecaption' then |
if type(key) == 'string' and key ~= 'description' and key ~= 'image' and key ~= 'imagecaption' and key ~= 'imagesize' then |
||
output = output .. '| <b>' .. key .. '</b>\n| ' .. value .. '\n|-\n' |
output = output .. '| <b>' .. key .. '</b>\n| ' .. value .. '\n|-\n' |
||
end |
end |
Revision as of 08:20, 14 April 2024
Welcome to Module:Module sandbox, a Wikipedia module sandbox. This page is itself a module, and it allows you to carry out experiments related to module editing. If you wish to experiment with article editing, use the Wikipedia Sandbox or your own user sandbox.
To edit, click the edit tab above, make your changes and click the Publish changes button when finished. Please do not place malicious Lua code here, or copyrighted, offensive, illegal or libelous content in the sandboxes. For assistance with Lua coding, try the technical forum at the Village Pump. There are also several template sandboxes you can use to carry out experiments:
You can also conduct tests using the Wikipedia Sandbox. For instance, to invoke this module there, edit it so that it includes: {{#invoke:Module sandbox}} |
More info
Sandbox games |
Usage
{{#invoke:Module sandbox|function_name}}
local p = {}
function p.infobox(frame)
local args = frame:getParent().args
local output = '{| class="infobox biography vcard" style="width: 22em;"\n'
local description = args.description or ""
if description ~= "" then
output = output .. '| style="text-align: center; background-color: ' .. (args.descriptionbgcolor or "#f2f2f2") .. '; color: ' .. (args.descriptioncolor or "inherit") .. '; font-weight: bold;" | ' .. description .. '\n|-\n'
end
if args.image then
local imageSize = args.imagesize or "150px" -- Default image size
output = output .. '| style="text-align: center;" | [[File:' .. args.image .. '|thumb|upright=1.5|' .. (args.imagecaption or "") .. '|' .. imageSize .. ']]\n|-\n'
end
for key, value in pairs(args) do
if type(key) == 'string' and key ~= 'description' and key ~= 'image' and key ~= 'imagecaption' and key ~= 'imagesize' then
output = output .. '| <b>' .. key .. '</b>\n| ' .. value .. '\n|-\n'
end
end
output = output .. '|}\n'
return output
end
return p