Module:TildeToPipe
Jump to navigation
Jump to search
Module:TildeToPipe
Utility module to perform text replacement of special characters.
This module provides the following function(s):
main- replaces all tilde~characters in a string with pipe|characters.
Usage
This module is primarily used as a practical alternative to the pipe trick {{!}} when writing pipe characters directly inside template invocations or wikitables would otherwise be impractical or error-prone.
{{#invoke:TildeToPipe|main|Item 1~Item 2~Item 3}}
Output:
Item 1|Item 2|Item 3
Parameters
main
- 1
- A string containing tildes
~to be replaced with pipes|.
local p = {}
function p.main(frame)
local input = frame.args[1]
if not input or input == "" then return "" end
-- replace all tildes with pipes
input = input:gsub("~", "|")
return input
end
return p