今天是2024年6月29日 第26周 星期六

代人,时大变了。

我们生活在大地上,但我们的梦想超越天空。

“模块:NoteTA”的版本间的差异

来自Akarin
跳到导航 跳到搜索
建立内容为“local z local HtmlBuilder = require( 'Module:HTMLBuilder' ) local WikitextLC = require( 'Module:WikitextLC' ) function Tcode( args ) if args.T ...”的新頁面)
 
第17行: 第17行:
 
      return ''
 
      return ''
 
    end
 
    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
 
end
  

2013年4月26日 (五) 21:56的版本

50px 模块文档[查看] [编辑] [历史] [清除缓存]

本模块用于执行{{NoteTA}}模板,请到模板页阅读具体用法。

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