Module:Base

Èn årtike di Wiccionaire.
I gn a nén co di dzo-pådje /doc pol notule d’ esplikêyes. Clitchîz cial po l’ ahiver.
local p = {}

-- load data if page exists
-- return table if exists, false if not
function p.load_data(m)
	local t = mw.title.new(m, "Module")
	-- nil if invalid title given
	-- DO NOT no use t.exists too expensive
	if t then
		local tc = t:getContent()
		if tc ~= nil and tc ~="" then
			return mw.loadData(t.fullText)
		end
	end
		
	return false
end

-- helper fonction to display an error message for user
function p.error_msg(s)
    local span = mw.html.create('span')
	span:attr('class', 'module-user-error')
        :css('color', 'red' )
        :wikitext(s)
	return tostring(span)
end

-- return hexadecimal notation of an unicode char
function p.hexunichr(frame)
	chr = frame.args[1]
    local ord = mw.ustring.codepoint(chr);
    local unihex = nil
    if ord < 65539 then 
    	unihex = string.format("%04x", ord)
    elseif ord < 1114111 then 
    	unihex = string.format("%08x", ord) 
    end
    unihex = "U+"..string.upper(unihex)
    return unihex
end

return p