Modul:Art pref/data
A modult a Modul:Art pref/data/doc lapon tudod dokumentálni
local title_object = mw.title.getCurrentTitle();
local content;
local ret = {}
if 10 ~= title_object.namespace then
content = title_object:getContent() or '';
end
if not content then
return ret;
end
local start = content:find('{{ *تفضيلات مقالة[%s\n]*[|}]');
if start then
local config_template = content:match ('%b{}', start);
if not config_template then
return ret;
end
local params_t = mw.text.split (config_template:gsub ('^{{%s*', ''):gsub ('[%s\n]*}}$', ''), '[%s\n]*|[%s\n]*');
table.remove (params_t, 1);
for _, param in ipairs (params_t) do
local k, v, t = param:match ('([^=]-)%s*=%s*(.+)'); -- <k> is the parameter name; <v> is parameter's assigned value
if k then
if k:find (':') then
t, k = k:match ('([^:]-):(.+)');
else
t="عام"
end
if ret[t] then
ret[t][k]=v
else
ret[t] = {[k]=v}
end
end
end
end
return ret