Jump to content

Module:Convert/show

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Johnuniq (talk | contribs) at 07:09, 28 October 2013 (replace with debug code). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

-- Stripped down to show frame:preprocess() weirdness.

local function show_examples(frame)
    local results = {}
    local fmt = '*<code>%s</code> → %s'
    for i, item in ipairs(frame.args) do
        item = item:gsub('!', '|')
        item = '{{convert/sandboxlua' .. (item:sub(1, 1) == '|' and '' or '|') .. item .. '}}'
        local a = mw.text.nowiki(item)
        local b = frame:preprocess(item)
        local c = fmt:format(a, b)
        mw.log('item = "' .. item .. '"\n')
        mw.log('nowiki = "' .. a .. '"\n')
        mw.log('preprocess = "' .. b .. '"\n')
        mw.log('format = "' .. c .. '"\n')
        table.insert(results, c)
    end
    return table.concat(results, '\n')
end

return {
    ['list'] = function (frame) return show_examples(frame) end,
}