Module:String

From Zelda Wiki, the Zelda encyclopedia
Jump to navigation Jump to search

local p = {}

local utilsString = require("Module:UtilsString")

-- Escape , for the benefit of templates which split by ,
function p.Escape(frame)
	local str = frame.args[1]
	str = string.gsub(str, ",", ",")
	return str
end

-- Useful for converting template arguments to class names for which kebab-case is standard
function p.KebabCase(frame)
	local str = frame.args[1]
	return utilsString.kebabCase(str)
end

-- Applies <nowiki></nowiki> tags to the _output_ of a template, rather than applying it to the template transclusion itself
function p.Nowiki(frame)
	local str = frame.args[1]
	return frame:callParserFunction("#tag:nowiki", str)
end

-- Used by [[Template:Page Name]]
function p.StripTrailingParentheses(frame)
	local str = frame.args[1]
	return str and utilsString.stripTrailingParentheses(str)
end

return p