FANDOM


-- This module is used to remove the part in brackets from the end of a string  
-- or the part after the first forward slash.
-- If first parameter of the parent template is unused, or <pageName> is left empty,
-- will return the undabbed title of the current page.
 
local p = {}
 
-- Removes brackets
-- Syntax: {{#invoke: dabBgone|main|<pageName>}}
function p.main( frame )
    local title = frame.args[1]
    if title == "{{{1}}}" or title == "" or title == nil then
        title = mw.title.getCurrentTitle().text
    end
 
    local pattern = "%(.[^%)]*%)$"
    local undabbed = string.gsub( title, pattern,"", 1 )
 
    return undabbed
end
 
-- Removes everything after the first forward-slash
-- Syntax: {{#invoke: dabBgone|rootpagename|<pageName>}}
function p.rootpagename( frame ) 
    local title = frame.args[1]
    if title == "{{{1}}}" or title == "" or title == nil then
        title = mw.title.getCurrentTitle().text
    end
 
    local pattern = "/.*$"
    local undabbed = string.gsub( title, pattern,"", 1 )
 
    return undabbed
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.