跳转到内容

模組:WikipediaHonors

维基百科,自由的百科全书

这是本页的一个历史版本,由SunAfterRain留言 | 贡献2020年2月14日 (五) 04:29编辑。这可能和当前版本存在着巨大的差异。

local data = require('Module:WikipediaHonor/data')

local z = {}

function extractAliases(item)
    allnames = {item['code']}
    for j, alias in ipairs(item['aliases']) do
        table.insert(allnames, alias)
    end
    return allnames
end

function z.data(frame)
	local wt = [=[
{|class="wikitable
|-
!資料類型!!編碼!!可使用的代碼!!名稱!!英文全名!!章節!!對應模板!!對應分類
	]=]
    for i, item in ipairs(data) do
        allnames = extractAliases(item)
        wt = wt .. string.format([=[
|-
|%s||%s
|
* %s
||%s||%s||%s||%s||%s
        ]=], 
        item['type'], 
        item['code'], 
        mw.text.listToText(allnames, '\n* ', '\n* '), 
        item['name'], 
        item['fullname'], 
        ((item['section'] and '[[WP:WPH#' .. item['section'] .. ']]') or ''), 
        ((item['template'] and '[[:Template:' .. item['template'] .. ']]') or ''), 
        ((item['category'] and '[[:Category:' .. item['category'] .. ']]') or '')
        )
    end
    wt = wt .. '|}'
    return frame:preprocess(wt)
end

return z