Module:Builder
Apparence
I gn a nén co di dzo-pådje /doc pol notule d’ esplikêyes. Clitchîz cial po l’ ahiver.
local p = {}
local base = require("Module:Base")
local category = require("Module:Categoreyes");
local contents = {}
local modele = nil
local error = nil
local errorcat = nil
-- set model frame & the default category for error
function p.init(frame, error_category)
if frame:getParent() then
modele = frame:getParent()
end
if error_category then
errorcat = error_category
end
end
-- add load_data
function p.load_data(d)
return base.load_data(d)
end
-- add category
function p.add_category(c, ns, ie)
category.store(c, true, ns, ie)
end
-- add content string in the table contents
function p.add_content(c)
if type(c) ~= 'string' then
c = tostring(c)
end
table.insert(contents, c)
end
-- return the content with categories or error box
function p.get_content()
local content = ''
if error then
local ns = mw.title.getCurrentTitle().namespace
if ns == 0 then
category.clear()
if errorcat then
category.store(errorcat)
else
category.store("Årtikes avou ene aroke dins on modele")
end
end
content = p.error_box()
else
content = tostring(table.concat(contents))
end
return content .. category.get_all()
end
-- set error text
function p.error(e)
error = e
end
-- return error informations in a box
function p.error_box()
html = mw.html.create()
if modele then
modeleName = mw.title.new(modele:getTitle())
html:wikitext("Aroke avou l’ modele [["..modeleName.fullText.."|"..modeleName.text.."]] : ")
end
html:wikitext(error)
if string.sub(error, -1) ~= "." then
html:wikitext(".")
end
frame = mw.getCurrentFrame()
return frame:expandTemplate{ title = "Bindea", args = {
sore = "stop",
tostring(html)
}}
end
return p