Difference between revisions of "Module:Sandbox/Evad37/X1"

From blackwiki
Jump to navigation Jump to search
blackwiki>Evad37
(just get coords)
blackwiki>Evad37
(.)
Line 9: Line 9:
 
end
 
end
  
p.content = function(frame)
+
p.getCoords = function(frame)
 
local parent = frame:getParent()
 
local parent = frame:getParent()
 
local title = mw.title.getCurrentTitle()
 
local title = mw.title.getCurrentTitle()
Line 17: Line 17:
 
table.insert(coords, coord)
 
table.insert(coords, coord)
 
end
 
end
return table.concat( coords, "\n")
+
return table.concat( coords, "\n\n")
 
end
 
end
  
 
return p
 
return p

Revision as of 14:54, 19 June 2020

Tests

{{#invoke:Sandbox/Evad37/X1|main}} → Module:Sandbox/Evad37/X1

Lua error: callParserFunction: function "#coordinates" was not found.

Lua error: callParserFunction: function "#coordinates" was not found.

Template:WikidataCoord

{{#invoke:Sandbox/Evad37/X1|getCoords}}



-- This module is a sandbox. It is also used for testing XFDcloser

local p = {}

p.main = function(frame) 
	local childFrame = frame:newChild{ title = "Sandbox", args = {} }
	local FULLPAGENAME = childFrame:preprocess( "{{FULLPAGENAME}}" )
	return FULLPAGENAME
end

p.getCoords = function(frame)
	local parent = frame:getParent()
	local title = mw.title.getCurrentTitle()
	local content = frame:preprocess(title:getContent())
	local coords = {}
	for coord in mw.ustring.gmatch(content, "<span class=\"geo\">(.-)</span>") do
		table.insert(coords, coord)
	end
	return table.concat( coords, "\n\n")
end

return p