ಮಾಡ್ಯೂಲ್:Toolbar: ಪರಿಷ್ಕರಣೆಗಳ ನಡುವಿನ ವ್ಯತ್ಯಾಸ

Content deleted Content added
generate more natural html if class and style arguments are absent
use a more efficient string-building algorithm
೧ ನೇ ಸಾಲು:
local p = {}
local args = {}
 
-- Get the keys of the numerical arguments that are present.
local function getArgNums(args)
local nums = {}
local tinsert = table.insert
for k, v in pairs(args) do
if type(k) == 'number' then
table.inserttinsert(nums, k)
end
end
೧೪ ನೇ ಸಾಲು:
end
 
local function makeToolbarItems(args)
-- Get numerical argument keys.
local nums = getArgNums(args)
-- Get the separator text.
local sep = (args.separator or 'pipe') .. '-separator'
೨೨ ನೇ ಸಾಲು:
-- Generate the toolbar items.
local ret = ''{}
local tinsert = table.insert
for i, v in ipairs(nums) do
tinsert(ret = ret .., args[v])
if nums[i + 1] then
ret = ret .. sep
end
end
return table.concat(ret, sep)
end
 
local function makeToolbar(args)
return mw.ustring.format(
local class = (args.class and (' ' .. args.class)) or ''
'<span class="plainlinks%s"%s>(%s)</span>',
local style = (args.style and (' style="' .. args.style .. '"')) or ''
local class = type(args.class) == 'string' and (' ' .. args.class)) or '',
local ret type(args.style) == '<span class="plainlinksstring' .. classand mw.ustring.format(' 'style="%s"', args.. style) ..or '>',
.. '(' .. makeToolbarItems(args) .. ')'
)
.. '</span>'
return ret
end
 
Line ೪೯ ⟶ ೪೫:
if frame == mw.getCurrentFrame() then
origArgs = frame:getParent().args
for k, v in pairs(frame.args) do
origArgs = frame.args
break
end
else
origArgs = frame
೫೪ ನೇ ಸಾಲು:
-- Strip whitespace and remove nil values
local args = {}
for k, v in pairs(origArgs) do
if type(v) == mw.text.trim(v)'string' then
v = mw.text.trim(v)
end
if v ~= '' then
args[k] = v
Line ೬೧ ⟶ ೬೪:
end
return makeToolbar(args)
end
"https://kn.wikipedia.org/wiki/ಮಾಡ್ಯೂಲ್:Toolbar" ಇಂದ ಪಡೆಯಲ್ಪಟ್ಟಿದೆ