Модуль:Новости: различия между версиями
Материал из AbduloverA.com
Adept (обсуждение | вклад) Нет описания правки |
Adept (обсуждение | вклад) Нет описания правки |
||
| Строка 3: | Строка 3: | ||
function p. | function p.render_text(frame) | ||
local pageName = frame.args[1]; | local pageName = frame.args[1]; | ||
local index = frame.args[2]; | local index = frame.args[2]; | ||
| Строка 19: | Строка 19: | ||
local rows = {} | local rows = {} | ||
for row in content:gmatch("|text=.[^}]+}-", "%a") do | for row in content:gmatch("|text=.[^}]+}-", "%a") do | ||
table.insert(rows, row) | table.insert(rows, row) | ||
end | end | ||
| Строка 31: | Строка 27: | ||
local trunced = string.gsub(str_p, "|text=", ""); | local trunced = string.gsub(str_p, "|text=", ""); | ||
mw.log(trunced); | mw.log(trunced); | ||
return trunced; | return trunced; | ||
end | end | ||
function p.render_date(frame) | |||
local pageName = frame.args[1]; | |||
local index = frame.args[2]; | |||
-- local pageName = "Шаблон:Новости"; | |||
-- local index = 1; | |||
local content = mw.title.new(pageName):getContent() | |||
if not content then | |||
return "Страница не найдена или пуста." | |||
end | |||
local rows = {} | |||
for row in content:gmatch("|date=.[^}]+}-", "%a") do | |||
table.insert(rows, row) | |||
end | |||
local result = {} | |||
str_p = rows[tonumber(index)] | |||
local trunced = string.gsub(str_p, "|text=", ""); | |||
mw.log(trunced); | |||
return trunced; | |||
end | |||
return p; | |||
Версия от 22:08, 27 января 2025
Для документации этого модуля может быть создана страница Модуль:Новости/doc
local p = {}
local str_p = ""
function p.render_text(frame)
local pageName = frame.args[1];
local index = frame.args[2];
-- local pageName = "Шаблон:Новости";
-- local index = 1;
local content = mw.title.new(pageName):getContent()
if not content then
return "Страница не найдена или пуста."
end
local rows = {}
for row in content:gmatch("|text=.[^}]+}-", "%a") do
table.insert(rows, row)
end
local result = {}
str_p = rows[tonumber(index)]
local trunced = string.gsub(str_p, "|text=", "");
mw.log(trunced);
return trunced;
end
function p.render_date(frame)
local pageName = frame.args[1];
local index = frame.args[2];
-- local pageName = "Шаблон:Новости";
-- local index = 1;
local content = mw.title.new(pageName):getContent()
if not content then
return "Страница не найдена или пуста."
end
local rows = {}
for row in content:gmatch("|date=.[^}]+}-", "%a") do
table.insert(rows, row)
end
local result = {}
str_p = rows[tonumber(index)]
local trunced = string.gsub(str_p, "|text=", "");
mw.log(trunced);
return trunced;
end
return p;