Module:Places: Difference between revisions

From Nguhcraft Wiki
Jump to navigation Jump to search
Created page with "local _m = {} local data = mw.loadJsonData(Data:Places) _m.countries = function(frame) local out = [==[ <table class="wikitable sortable"> <th> <td>Common name</td> <td>Full name</td> <td>Ruler</td> <td>Ruler title</td> <td>Date founded</td> <td>Capital</td> <td>Code-2</td> <td>Code-3</td> <td>UŊ Member</td> </th> ]==] for _, c in ipairs(data.places) do if not c.not_ngation and not c.condominium and not c.reason_dissolved and not c.reserved then ou..."
 
No edit summary
Line 6: Line 6:
local out = [==[
local out = [==[
<table class="wikitable sortable">
<table class="wikitable sortable">
<th>
<tr>
<td>Common name</td>
<th>Common name</td>
<td>Full name</td>
<th>Full name</td>
<td>Ruler</td>
<th>Ruler</td>
<td>Ruler title</td>
<th>Ruler title</td>
<td>Date founded</td>
<th>Date founded</td>
<td>Capital</td>
<th>Capital</td>
<td>Code-2</td>
<th>Code-2</td>
<td>Code-3</td>
<th>Code-3</td>
<td>UŊ Member</td>
<th>UŊ Member</td>
</th>
</tr>
]==]
]==]
for _, c in ipairs(data.places) do
for _, c in ipairs(data.places) do

Revision as of 23:21, 18 November 2025

Documentation for this module may be created at Module:Places/doc

local _m = {}

local data = mw.loadJsonData([[Data:Places]])

_m.countries = function(frame)
	local out = [==[
<table class="wikitable sortable">
<tr>
	<th>Common name</td>
	<th>Full name</td>
	<th>Ruler</td>
	<th>Ruler title</td>
	<th>Date founded</td>
	<th>Capital</td>
	<th>Code-2</td>
	<th>Code-3</td>
	<th>UŊ Member</td>
</tr>
]==]
	for _, c in ipairs(data.places) do
		if not c.not_ngation and not c.condominium and not c.reason_dissolved and not c.reserved then
			out = out .. "<tr>"
			out = out .. "<td>" .. frame:expandTemplate{title = "Banner", args = {c.code2}}
			          .. " " .. (c.common_name and ("[[" .. c.common_name .. "]]") or "") .. "</td>"
			out = out .. "<td>" .. (c.name or "") .. "</td>"
			if not c.ruler then out = out .. "<td></td>"
			elseif type(c.ruler) == "table" then
				out = out .. "<td>"
				for i, r in ipairs(c.ruler) do out = out .. (i ~= 1 and ", " or "") .. r end
				out = out .. "</td>"
			elseif c.ruler_link then
				out = out .. "<td>[[" .. c.ruler_link .. "|" .. c.ruler .. "]]</td>"
			else out = out .. "<td>[[" .. c.ruler .. "]]</td>"
			end
			out = out .. "<td>" .. (c.ruler_title or "") .. "</td>"
			if not c.date_founded then out = out .. "<td></td>" else
				out = out .. "<td>" .. c.date_founded[1] .. "-" .. c.date_founded[2] .. "-" .. c.date_founded[3] .. "</td>"
			end
			out = out .. "<td>" .. (c.capital or "") .. "</td>"
			out = out .. "<td>" .. c.code2 .. "</td>"
			out = out .. "<td>" .. c.code3 .. "</td>"
			out = out .. "<td>" .. (c.ung == "member" and "yes" or "no") .. "</td>"
			out = out .. "</tr>"
		end
	end
	out = out .. [[</table>]]
	return out
end
return _m