Modul:Tools

Aus skandinavien-wiki.net

Die Dokumentation für dieses Modul kann unter Modul:Tools/doc erstellt werden

local check    = require('Modul:Check2')

local function strtok ( stringStr, delimiterStr )
	local s = stringStr..delimiterStr
	local words = {}
	for w in (s):gmatch('([^'..delimiterStr..']*)'..delimiterStr..'') do 
	    table.insert(words, w) 
	end
	return words
end

local function rmNamespace ( pageName )
	return strtok(pageName,':')[2] or pageName
end

local tools = {}

function tools._getParameters( frame_args, arg_list )
    local new_args = {};
    local index = 1;
    local value;
    
    for i,arg in ipairs( arg_list ) do
        value = frame_args[arg]
        if value == nil then
            value = frame_args[index];
            index = index + 1;
        end
        new_args[arg] = value;
    end
    
    return new_args;
end 

function tools.firstBasepagename (frame)

    local new_args = tools._getParameters( frame.args, {'page'} );
    local page = new_args['page'] or '';
    return strtok(pageName,'/')[1] or page
end

return tools