Module:Sandbox/Aurelain/Link: Difference between revisions

From Heroes of Might and Magic: Olden Era Official Wiki
Created page with "-- Usage: see Module:Link/doc local p = {} -- Displays a variable ------------------------------------------------------------------------------------------------------------------------ local function dump(target) return '<pre>' .. mw.dumpObject(target) .. '</pre>' end ------------------------------------------------------------------------------------------------------------------------ function p.clean(frame) local text = frame.args[1] return text end r..."
 
No edit summary
Line 11: Line 11:
function p.clean(frame)
function p.clean(frame)
     local text = frame.args[1]
     local text = frame.args[1]
    text = text:replace('Basic ', '')
    text = text:replace('Advanced ', '')
    text = text:replace('Expert ', '')
    text = text:replace('_special', '')
    text = text:replace('Masterful ', '')
     return text
     return text
end
end


return p
return p

Revision as of 17:01, 25 August 2026

This module is intended as a supporting muscle for the LinkIcon template.

clean()

Removes the following words from a text:

  • Basic 
  • Advanced 
  • Expert 
  • _special
  • Masterful 

Afterwords, appends a language code, if provided and necessary.

Input:

{{#invoke:Sandbox/Aurelain/Link|clean
|Lorem,Basic ,Advanced ,Expert ,_special,Masterful ,Ipsum
}}

Output: Lua error at line 13: attempt to call method 'replace' (a nil value).


-- Usage: see Module:Link/doc
local p = {}

-- Displays a variable
------------------------------------------------------------------------------------------------------------------------
local function dump(target)
    return '<pre>' .. mw.dumpObject(target) .. '</pre>'
end

------------------------------------------------------------------------------------------------------------------------
function p.clean(frame)
    local text = frame.args[1]
    text = text:replace('Basic ', '')
    text = text:replace('Advanced ', '')
    text = text:replace('Expert ', '')
    text = text:replace('_special', '')
    text = text:replace('Masterful ', '')
    return text
end

return p