יחידה:שונות
מראה
ניתן ליצור תיעוד על היחידה הזאת בדף יחידה:שונות/תיעוד
--[[
יחידה זו מיועדת לפונקציות שנועדו להחליף תבניות ספציפיות בוויקיפדיה בעברית, בייחוד תבניות יקרות או מסובכות, שבלואה הופכות לזולות או פשוטות יותר
פונקציה ראשונה, "שער" מיועדת להחליף את תבנית:שער
]]
-- replaces old template שער
local function goal( frame )
local param = frame.args[1] or frame:getParent().args[1] or ''
local num
param, num = param:gsub("([0-9+]+)[ ,']*", "%1' ") -- replace all numbers (incl. plus sign, for "90+2" mark, optionally followed by any number of commas, spaces, and single quotes with desiderd form
param = param:gsub(' (%d)', ', %1')
param = param:gsub('%s*,+%s*,+%s*', ', ') -- can be a result of other text injected between 2 goals, such as {{פנדל}}
param = mw.text.trim(param)
hint = num == 1 and 'הובקע שער בדקה ה-' or num > 1 and 'הובקעו שערים בדקות ה-' or ''
hint = hint:gsub("'", '')
param = mw.ustring.format('[[קובץ:Soccerball shade.svg|13px|%s %s|קישור=]]<span style="font-size:10px;vertical-align:middle;white-space:nowrap;"> %s</span>', hint, param, param)
return frame:preprocess(param)
end
return {
['שער'] = goal,
}