Jump to content

Module:Stem

ពីWiktionary

Documentation for this module may be created at Module:Stem/doc

-- @brief
-- returns PAGENAME without last or some last characters
-- @param
-- 'n': number of characters to exclude from PAGENAME ending
-- If not declared then PAGENAME without last character is returned
 
_module ={}
 
function _module.stem(frame)
    local args = frame.args
    local pargs = frame:getParent().args    
    local num = 2
    if args['n'] ~= nil then
        if tonumber(args['n']) > 1 then 
            num = 1 + tonumber(args['n']) 
        end
    end
    PAGENAME = mw.title.getCurrentTitle().text  
--    NAMESPACE = mw.title.getCurrentTitle().nsText
    return mw.ustring.sub(PAGENAME,1,-num)
end
 
-- for debuging in debug console
-- using print(p.stemtest())
function _module.stemtest()
    arg1 = 'naczynie'
    num = 2
    return mw.ustring.sub(arg1,1,-num)
end
return _module