Mudanças entre as edições de "Módulo:MapaJson"
Ir para navegação
Ir para pesquisar
(modulo lua para processar o Json do mapa) |
|||
| (13 revisões intermediárias pelo mesmo usuário não estão sendo mostradas) | |||
| Linha 1: | Linha 1: | ||
local p = {} | local p = {} | ||
function p.getDados(frame) | |||
function p. | local pageName = frame.args[1] or '' | ||
local | |||
if pageName == '' then | |||
if | return '' | ||
end | end | ||
local title = mw.title.new(pageName) | |||
if not title or not title.exists then | |||
return '' | |||
local | |||
return ' | |||
end | end | ||
local jsonContent = title:getContent() or '' | |||
-- Apenas remover espaços extras | |||
jsonContent = jsonContent:gsub("\n", "") | |||
jsonContent = jsonContent:gsub("\r", "") | |||
jsonContent = jsonContent:gsub("\t", " ") | |||
jsonContent = jsonContent:gsub(" +", " ") | |||
return jsonContent | |||
end | end | ||
return p | return p | ||
Edição atual tal como às 14h24min de 11 de abril de 2026
A documentação para este módulo pode ser criada em Módulo:MapaJson/doc
local p = {}
function p.getDados(frame)
local pageName = frame.args[1] or ''
if pageName == '' then
return ''
end
local title = mw.title.new(pageName)
if not title or not title.exists then
return ''
end
local jsonContent = title:getContent() or ''
-- Apenas remover espaços extras
jsonContent = jsonContent:gsub("\n", "")
jsonContent = jsonContent:gsub("\r", "")
jsonContent = jsonContent:gsub("\t", " ")
jsonContent = jsonContent:gsub(" +", " ")
return jsonContent
end
return p