Template:EditButton/CheckList

{{#lua: --%% Preprocessing %%-- local list = {} -- データリスト local i = 0; for line in string.gmatch(stdin,"[^\n]+") do --%% 空行を飛ばして読み込む %%--

 list[i] = string.gsub(line, "^%s*(.-)%s*$", "%1");
 i = i + 1;

end --%% Display Setting %%-- print('{{#form' .. 'tag:form|action="/wiki/ " method="post"|') print('{{#form' .. 'tag:input|type="submit" value="update"}}
')

local head, body; for i = 0, table.maxn(list) do

 head = string.match(list[i], "^([\*\#]+%s*)");
 --%% If *,# precedes a line, then place a checkbox, otherwise not. %%--
 if (head ~= nil) then
   body = string.sub(list[i],string.len(head)+1);
   --%% Check whether items are already selected.%%--
   if (string.match(" ", " " .. body .. " ", 0) or
       string.match(" ", "^" .. body .. " ", 0) or
       string.match(" ", " " .. body .. "$", 0) ) then
     checked = ' checked="yes"' 
   else
     checked = 
   end
   print(head .. '{{#form' .. 'tag:input|type="checkbox" value="' .. body .. '" name="list[]" id="' .. body .. '"' .. checked .. '}}{{#form' .. 'tag:label|for="' .. body .. '"|' .. body .. '}}
') else print(list[i]); end

end print('{{#form' .. 'tag:input|type="hidden" name="listpage" value=" "}}') print('{{#form' .. 'tag:input|type="hidden" name="title" value=" "}}') print('{{#form' .. 'tag:input|type="hidden" name="separator" value=" "}}') print('{{#form' .. 'tag:input|type="hidden" name="hookinsert" value="__HOOK_AND_INSERT__"}}') print('{{#form' .. 'tag:input|type="submit" value="update"}}') print('}}') |{{ }} }}