Module:Script-IS: Difference between revisions

From Mizuumi Wiki
Jump to navigation Jump to search
m (fixing syntax)
m (fixed logic)
Line 14: Line 14:
end
end
--get the string done
--get the string done
ret = ""
for index, prop in ipairs(t) do
for index, prop in ipairs(t) do
if prop:sub(1,1) == "%s" then
if prop:sub(1,1) == "%s" then
prop = prop:sub(2,-1)
prop = prop:sub(2,-1)
end
end
if index ~= 1 then
prop = "{{Property-IS|" .. prop
ret = ret .. ", "
prop = prop .. "|IGNOREPROPERTYERROR}}"
end
ret = ret .. "{{Property-IS|" .. prop .. "|IGNOREPROPERTYERROR}}"
end
end
table.concat(t,", ")
return ret
return ret

Revision as of 09:43, 11 May 2023

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
	for index, prop in ipairs(t) do
		if prop:sub(1,1) == "%s" then
			prop = prop:sub(2,-1)
		end
		prop = "{{Property-IS|" .. prop
		prop = prop .. "|IGNOREPROPERTYERROR}}"
	end
	
	table.concat(t,", ")
	
	return ret
end

return p