恪別𡧲版𢯢𢷮𧵑「模庉:Danh sách」
交面
Trong Dang (討論 | 㨂𢵰) 造張㵋貝內容「---Các hàm để xây dựng danh sách. local p = {} local viet ---Cho ra các tham số như một danh sách nội dòng. -- Hàm này hỗ trợ số tham số không hạn chế. function p.inlineList(frame) local contentFrame = frame if not frame.args[1] then contentFrame = frame:getParent() end local start = tonumber(contentFrame.args.start or frame.args.start or 1) or 1 local insep = contentFrame.args.insep local items = {}…」 𥮋:𢯢𢷮移動 Mobile web edit Advanced mobile edit |
SaigonSarang (討論 | 㨂𢵰) n 𠊝替文本-「Mô đun:」成「Module:」 |
||
𣳔30: | 𣳔30: | ||
if contentFrame.args.sorted and tonumber(contentFrame.args.sorted) == 1 then | if contentFrame.args.sorted and tonumber(contentFrame.args.sorted) == 1 then | ||
viet = viet or require " | viet = viet or require "Module:Quốc ngữ" | ||
table.sort(items, viet.comp) | table.sort(items, viet.comp) | ||
end | end |
版㵋一𣅶09:46、𣈜25𣎃3𢆥2025
固体𢪏材料𧗱模庉尼在模庉:Danh sách/材料。
---Các hàm để xây dựng danh sách.
local p = {}
local viet
---Cho ra các tham số như một danh sách nội dòng.
-- Hàm này hỗ trợ số tham số không hạn chế.
function p.inlineList(frame)
local contentFrame = frame
if not frame.args[1] then contentFrame = frame:getParent() end
local start = tonumber(contentFrame.args.start or frame.args.start or 1) or 1
local insep = contentFrame.args.insep
local items = {}
for i, arg in ipairs(contentFrame.args) do
if i >= start then
local item = tostring(mw.text.trim(arg))
if #item > 0 then
if insep then
local subitems = mw.text.split(item, insep)
for i, subitem in ipairs(subitems) do
table.insert(items, subitem)
end
else
table.insert(items, item)
end
end
end
end
if contentFrame.args.sorted and tonumber(contentFrame.args.sorted) == 1 then
viet = viet or require "Module:Quốc ngữ"
table.sort(items, viet.comp)
end
local format = contentFrame.args.format
if format then
for i, item in ipairs(items) do
items[i] = mw.ustring.format(format, item)
end
end
local space = contentFrame.args.space or frame.args.space or " "
local conj = contentFrame.args.conj or frame.args.conj
if #items > 1 and conj then
items[#items] = conj .. space .. items[#items]
end
local output
if #items == 2 and conj then
output = items[1] .. space .. items[2]
else
local sep = contentFrame.args.sep or frame.args.sep or ","
output = table.concat(items, sep .. space)
end
if #output < 1 and contentFrame.args.placeholder then
output = contentFrame.args.placeholder
end
return output
end
return p