Module:Distinguish: Difference between revisions

From FiguraMC
PenguinEncounter (talk | contribs)
Use template arguments (instead of #invoke arguments)
No edit summary
Line 6: Line 6:
table.insert(final, "[[" .. v .. "]]")
table.insert(final, "[[" .. v .. "]]")
end
end
local sep = " "
if #final > 1 then
if #final > 1 then
final[#final] = "or " .. final[#final]
final[#final] = "or " .. final[#final]
if #final > 2 then
sep = ", "
else
sep = " "
end
end
end
return frame:expandTemplate{title = "Hatnote", args = {"Not to be confused with " .. table.concat(final, (#final <= 2 and " ") or ", ") .. "."}}
return frame:expandTemplate{title = "Hatnote", args = {"Not to be confused with " .. table.concat(final, sep) .. "."}}
end
end


return {["hatnote"] = hatnoteDistinguish}
return {["hatnote"] = hatnoteDistinguish}

Revision as of 01:26, 29 September 2024

  • Not to be confused with .
  • Not to be confused with Foo.
  • Not to be confused with Foo or Bar.
  • Not to be confused with Foo, Bar, or Baz.

function hatnoteDistinguish(frame)
	local args = frame:getParent().args
	local final = {}
	
	for k, v in ipairs(args) do
		table.insert(final, "[[" .. v .. "]]")
	end
	local sep = " "
	if #final > 1 then
		final[#final] = "or " .. final[#final]
		if #final > 2 then
			sep = ", "
		else
			sep = " "
		end
	end
	return frame:expandTemplate{title = "Hatnote", args = {"Not to be confused with " .. table.concat(final, sep) .. "."}}
end

return {["hatnote"] = hatnoteDistinguish}