「第2回エンペディア大賞」が2月いっぱい開催中です。2024年に作成された記事の中から、お気に入りの記事に投票しましょう!
モジュール:TableCSV
ナビゲーションに移動
検索に移動
local p = {}
function p.error(message)
return '<strong class="error">エラー:' .. message .. '</strong>'
end
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame, {
wrappers = 'Template:TableCSV'
})
local csv = args.csv or ''
-- csvを一旦2次元配列にする
local tbl = require('Module:CSV').toArr2D({csv})
-- Arr2DToWikiTbl関数の引数を作る
local toWikiArgs = {tbl}
-- 属性
toWikiArgs.cls = args.cls or ''
toWikiArgs.id = args.id or ''
toWikiArgs.css = args.css or ''
toWikiArgs.cap = args.cap or ''
-- 左右上下を何行/列だけ表ヘッダーとするか の設定
local thArgsDirection = {'thLeft', 'thTop', 'thRight', 'thBottom'}
for i, thArgDirec in pairs(thArgsDirection) do
local thArg = tonumber(args[thArgDirec] or '0')
toWikiArgs[thArgDirec] = thArg ~= nil and thArg or 0
end
-- 2次元配列をWikiテーブルにする
return require('Module:TableUtil').arr2DToWikiTbl( toWikiArgs )
end
return p