跳转到内容

模組:NoteTA

被永久保护的模块
维基百科,自由的百科全书

这是本页的一个历史版本,由Liangent留言 | 贡献2013年4月26日 (五) 13:56编辑。这可能和当前版本存在着巨大的差异。

local z
local HtmlBuilder = require( 'Module:HTMLBuilder' )
local WikitextLC = require( 'Module:WikitextLC' )

function Tcode( args )
    if args.T ~= nil and args.T ~= '' then
        local builder = HtmlBuilder.create()
        local div = builder.tag( 'div' )
            .attr( 'id', 'noteTA-title' )
            .attr( 'data-noteta-code', mw.uri.encode( args.T ) )
            .wikitext( WikitextLC.title( args.T ) )
        if args.dt ~= nil and args.dt ~= '' then
            div.attr( 'data-noteta-desc', mw.uri.encode( args.T ) )
        end
        return tostring( builder )
    else
        return ''
    end
end

function group( name )
    if name == nil or name == '' then
        return ''
    end
    local title = mw.title.makeTitle( 'Template', 'CGroup/' .. name )
    if title.exists then
        return frame:expandTemplate( title )
    else
        return tostring( HtmlBuilder.create()
            .tag( 'div' )
                .attr( 'id', 'noteTA-group-' .. mw.uri.anchorEncode( name ) )
                .attr( 'class', 'noteTA-missing' )
                .attr( 'data-noteta-group', name )
            .allDone() )
    end
end

function Gcode( args )
    local code = {}
    for i = 1, 30 do
        code:insert( group( args['G' .. i] ) )
    end
    code = code:concat()
    if code ~= '' then
        code = tostring( HtmlBuilder.create()
            .tag( 'div' )
                .attr( 'id', 'noteTA-group' )
                .wikitext( code )
            .allDone() )
    end
    return code
end

function z.main( frame )
    local args = frame:getParent().args
end

return z