יחידה:String: הבדלים בין גרסאות בדף
מ הפעיל/ה הגנה על הדף "יחידה:String": דף בשימוש רב ([עריכה=רק בדוקי עריכות אוטומטית מורשים] (בלתי מוגבלת בזמן) [העברה=רק בדוקי עריכות אוטומטית מו... |
מ Changed protection level for "Module:String": request at RfP ([Edit=Require template editor access] (indefinite) [Move=Require template editor access] (indefinite)) |
||
| שורה 383: | שורה 383: | ||
end | end | ||
--[[ | --[[ | ||
simple function to pipe string.rep to templates. | |||
]] | ]] | ||
str. | |||
local | function str.rep( frame ) | ||
local repetitions = tonumber( frame.args[2] ) | |||
if not repetitions then | |||
return str._error( 'function rep expects a number as second parameter, received "' .. ( frame.args[2] or '' ) .. '"' ) | |||
end | |||
return string.rep( frame.args[1] or '', repetitions ) | |||
end | end | ||
--[[ | --[[ | ||
| שורה 423: | שורה 423: | ||
function str._error( error_str ) | function str._error( error_str ) | ||
local frame = mw.getCurrentFrame(); | local frame = mw.getCurrentFrame(); | ||
local error_category = frame.args.error_category or ' | local error_category = frame.args.error_category or 'Errors reported by Module String'; | ||
local ignore_errors = frame.args.ignore_errors or false; | local ignore_errors = frame.args.ignore_errors or false; | ||
local no_category = frame.args.no_category or false; | local no_category = frame.args.no_category or false; | ||
| שורה 433: | שורה 433: | ||
local error_str = '<strong class="error">String Module Error: ' .. error_str .. '</strong>'; | local error_str = '<strong class="error">String Module Error: ' .. error_str .. '</strong>'; | ||
if error_category ~= '' and not str._getBoolean( no_category ) then | if error_category ~= '' and not str._getBoolean( no_category ) then | ||
error_str = '[[Category:' .. error_category .. ']]' .. error_str; | |||
end | end | ||
| שורה 470: | שורה 468: | ||
return mw.ustring.gsub( pattern_str, "([%(%)%.%%%+%-%*%?%[%^%$%]])", "%%%1" ); | return mw.ustring.gsub( pattern_str, "([%(%)%.%%%+%-%*%?%[%^%$%]])", "%%%1" ); | ||
end | end | ||
return str | return str | ||