モジュール:Sidebar

提供:雑学ペディア
ナビゲーションに移動 検索に移動

スクリプトエラー: モジュール「Main」はありません。


local p = {};

function p.main( frame )
  local args = require('モジュール:Arguments').getArgs(frame, {wrappers = 'テンプレート:Sidebar', removeBlanks = false})

  -- 使用変数のnil避け

  local groupcolor = '';
  local group_temp = '';
  local group = '';
  local list_temp = '';
  local list = '';

  local line = '';
  local temp = '';

  -- config 引数を受け取る
  groupcolor = args.groupcolor or '';
  if groupcolor == '' or nil then
    groupcolor = '#cedaf2';
  end

  -- ループ行の開始 / そんなに何書くんだと思いつつ最大100行
  for i = 1, 100, 1 do
    temp = '';

    -- 引数を受け取る
    group_temp = 'group' ..i;
    group = args[group_temp] or '';
    list_temp = 'list' ..i;
    list = args[list_temp] or '';

    -- 読み込みがなくなったらループを抜ける
    temp = group ..list;
    if temp == '' or nil then
      break
    end

    -- list の内容があった場合のみ行を追加
    if list ~= '' or nil then
      temp = '<tr>';
      temp = temp ..'<td style="background: ' ..groupcolor ..'; text-align: right; padding-right: 2px; font-weight: bold; white-space: nowrap;">' .. group ..'</td>';
      temp = temp ..'<td style="padding-left: 2px;">' ..list ..'</td>';
      temp = temp ..'</tr>';

      -- 行を加算
      line = line ..temp;
    end
end

  return line
end

return p