مۆدیوول:Art pref/data

لە ئینسایکڵۆپیدیای ئازادی ویکیپیدیاوە
بەڵگەدارکردنی مۆدیوول[دروست بکە]
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