Module:Script-IS

From Mizuumi Wiki
Revision as of 09:08, 11 May 2023 by Yuki-chr (talk | contribs) (created script and implemented multiprop function)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:Script-IS/doc

local p = {}

--custom script for the IS wiki, feel free to make a copy of it or take any part of the code for other wikis

--split multiple properties passed as a single param to a template call and return the converted property text
function p.multiprop(frame)
	
	local str = frame.args(1)
	local sep = ","
	local t={}
	--split properties
	for str in string.gmatch(str, "([^"..sep.."]+)") do
			table.insert(t, str)
	end
	--get the string done
	ret = ""
	first = true
	for prop in t do
		if prop:sub(1,1) == "%s" then
			prop = prop:sub(2,-1)
		end
		if not first then
			ret = ret .. ", "
		end
		ret = ret .. "{{Property-IS|" .. prop .. "|IGNOREPROPERTYERROR}}"
		first = false
	end
	
	return ret
end

return p