Module:Cmap: Difference between revisions

From Heroes 3 wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 3: Line 3:
function p.cmap(frame)
function p.cmap(frame)
if frame.args[1] then
if frame.args[1] then
return mw.ustring.gsub(frame.args[1], '400px', '100px')[1]
smaller, _ = mw.ustring.gsub(frame.args[1], '400px', '100px')
return smaller
end
end
return ''
return ''

Revision as of 19:06, 6 January 2024

Returns arg1 with all instances of arg2 replaced with arg3.

Example

{{#invoke:cmap|cmap|needle in haystack|needle|hay}}
needle in haystack

local p = {} --p stands for package

function p.cmap(frame)
	if frame.args[1] then
		smaller, _ = mw.ustring.gsub(frame.args[1], '400px', '100px')
		return smaller
	end
	return ''
end

return p