Dota 2 Вики
Advertisement

Документация для Модуль:Animate Перейти к коду ↴ [ править | очистить ]

Reality Rift icon
▶️ Planeshift.
Документацию для этого шаблона или модуля можно найти в Template:Animate.
Вы можете быть перенаправлены на другой язык вики, если перевод недоступен.


Зависимости

local p = {}
local getArgs = require('Модуль:Arguments').getArgs
local split = require('Модуль:Split')


function p.main(frame)
  local args = getArgs(frame, {
    wrappers = {
      'Шаблон:Animate'
    }
  })
  return p._main(args)
end

function p._main(args)
  if args[1] then
    local size = args[2] or ''
    if size ~= '' then size = '|' .. size end
    local link = args['link'] or ''
    if link ~= '' then link = '|link=' .. link end
    
    local images = {}
    for _,image in ipairs(split(args[1], '%s*;%s*')) do
      if image == '' then
        table.insert(images, '<span><br></span>')
      else
        table.insert(images, '<span>[[File:' .. image .. size .. link .. ']]</span>')
      end
    end
    images[1] = images[1]:gsub('^<span>', '<span class="animated-active">')
    
    return mw.html.create('span')
      :attr('class', 'animated')
      :wikitext(table.concat(images))
  else
    return error('Проверьте ввод', 0)
  end
end

function p.text()
  local args = getArgs()
  return p._text(args)
end

function p._text(args)
  if args[1] then
    local result = {}
    for _,text in ipairs(split(args[1], '%s*;%s*')) do
      if text == '' then
        table.insert(result, '<span><br></span>')
      else
        table.insert(result, '<span>' .. text .. '</span>')
        table.insert(result, '<span>' .. text .. '</span>')
      end
    end
    result[1] = result[1]:gsub('^<span>', '<span class="animated-active">')
    
    return mw.html.create('span')
      :attr('class', 'animated')
      :wikitext(table.concat(result))
  else
    return error('Проверьте ввод', 0)
  end
end


return p
Advertisement