ಮಾಡ್ಯೂಲ್:Toolbar: ಪರಿಷ್ಕರಣೆಗಳ ನಡುವಿನ ವ್ಯತ್ಯಾಸ
Content deleted Content added
use a more efficient string-building algorithm |
allow access to the p._main function from other modules, return the blank string if no arguments were specified, and switch indentation to tabs |
||
೧ ನೇ ಸಾಲು:
local p = {}
-- Get the keys of the numerical arguments that are present.▼
local function getArgNums(args)
▲ -- Get the keys of the numerical arguments that are present.
local nums = {}▼
local nums =
local tinsert = table.insert end
local function makeToolbarItems(args)
local nums = getArgNums(args)
▲ sep = mw.message.new(sep):plain()
local ret = {}▼
if #ret > 0 then
▲ local tinsert = table.insert
▲ for i, v in ipairs(nums) do
▲ tinsert(ret, args[v])
▲ end
▲ return table.concat(ret, sep)
end
return mw.ustring.format(▼
if not toolbarItems then return '' end -- Return the blank string if no arguments were specified, rather than returning empty brackets
'<span class="plainlinks%s"%s>(%s)</span>',▼
type(args.class) == 'string' and ' ' .. args.class or '',▼
type(args.style) == 'string' and mw.ustring.format(' style="%s"', args.style) or '',▼
▲ makeToolbarItems(args)
toolbarItems
)▼
end
function p.main(frame)
▲ -- Strip whitespace and remove nil values
▲ for k, v in pairs(origArgs) do
▲ if type(v) == 'string' then
end
▲ v = mw.text.trim(v)
if v ~= ''
end
▲ args[k] = v
▲ end
▲ return makeToolbar(args)
end
return p
|