יחידה:פרמטרים: הבדלים בין גרסאות בדף
מראה
אין תקציר עריכה |
אין תקציר עריכה |
||
| שורה 7: | שורה 7: | ||
local numbered = 0 | local numbered = 0 | ||
local mustnum = tonumber(frame.args[1]) | local mustnum = tonumber(frame.args[1]) | ||
local suggestions = mw.loadData(template .. "/ניהול_פרמטרים"); | --local suggestions = mw.loadData(template .. "/ניהול_פרמטרים"); | ||
local suggestions = mw.require('תבנית:סדרת_טלוויזיה1/ניהול_פרמטרים'); | |||
for k1, v1 in pairs( suggestions ) do | for k1, v1 in pairs( suggestions ) do | ||
ans = out(ans, v1) | ans = out(ans, v1) | ||
גרסה מ־11:53, 8 במאי 2015
function foo(frame)
local ans = ""
local pframe = frame:getParent()
local template = pframe:getTitle()
local empty = false
local start = true
local numbered = 0
local mustnum = tonumber(frame.args[1])
--local suggestions = mw.loadData(template .. "/ניהול_פרמטרים");
local suggestions = mw.require('תבנית:סדרת_טלוויזיה1/ניהול_פרמטרים');
for k1, v1 in pairs( suggestions ) do
ans = out(ans, v1)
end
for k, v in pairs( pframe.args ) do
if type( k ) == 'string' then
ans = checknamed(k, ans, frame)
else
numbered = k
if (k == 1 and mw.text.trim(v) == "" and start) then
empty = true
end
end
start = false
end
if (mustnum < numbered and not (empty and mustnum == 0 and numbered == 1)) then
ans = out (ans, "צריך מקסימום " .. mustnum .. " פרמטרים, ישנם " .. numbered)
end
if (ans == "") then
return ans
end
return "<div class=error> '''שגיאת פרמטרים ב[[" .. template .. "]]:<br/>"
.. ans .. "''' </div>[[קטגוריה:שגיאות פרמטריות]]"
end
function checknamed(k, ans, frame)
local i = 2
while (frame.args[i] ~= nil) do
if (frame.args[i] == k) then
return ans
end
i = i + 1
end
return out(ans, "פרמטר לא ידוע: ''" .. k .. "''")
end
function out(ans, new)
return ans .. new .. "</br>"
end
return {
['main'] = foo
}