Diferencia entre revisiones de «Módulo:Ficha»

Sin resumen de edición
Sin resumen de edición
Línea 5: Línea 5:
local p = {}
local p = {}
   
   
local HtmlBuilder = require('Módulo:HtmlBuilder')
local HtmlBuilder = require('Module:HtmlBuilder')
   
   
local args
local args
Línea 11: Línea 11:
   
   
function union(t1, t2)
function union(t1, t2)
     -- devuelve la unión de los valores de dos tablas, como una secuencia
     -- return the union of the values of two tables, as a sequence
     local vals = {}
     local vals = {}
     for k, v in pairs(t1) do
     for k, v in pairs(t1) do
Línea 159: Línea 159:


local function renderRows()
local function renderRows()
     local rownums = union(getArgNums('sección'), getArgNums('datos'))
     local rownums = union(getArgNums('header'), getArgNums('data'))
     table.sort(rownums)
     table.sort(rownums)
     for k, num in ipairs(rownums) do
     for k, num in ipairs(rownums) do
         addRow({
         addRow({
             header = args['sección' .. num],
             header = args['header' .. num],
             label = args['etiqueta' .. num],
             label = args['label' .. num],
             data = args['datos' .. num],
             data = args['data' .. num],
             datastyle = args.datastyle,
             datastyle = args.datastyle,
             class = args['class' .. num],
             class = args['class' .. num],
Línea 196: Línea 196:
local function renderTrackingCategories()
local function renderTrackingCategories()
     if args.decat ~= 'yes' and #(getArgNums('data')) == 0 and mw.title.getCurrentTitle().namespace == 0 then
     if args.decat ~= 'yes' and #(getArgNums('data')) == 0 and mw.title.getCurrentTitle().namespace == 0 then
         root.wikitext('[[Categoría:Wikipedia:Artículos que usan ficha sin datos en filas]]')
         root.wikitext('[[Category:Articles which use infobox templates with no data rows]]')
     end
     end
end
end
Línea 204: Línea 204:
         root = HtmlBuilder.create('table')
         root = HtmlBuilder.create('table')
          
          
         root          
         root
             .addClass('infobox_v2')
             .addClass('infobox')
             .addClass(args.bodyclass)
             .addClass(args.bodyclass)
             .attr('cellspacing', 3)
             .attr('cellspacing', 3)
Línea 235: Línea 235:
function p.infobox(frame)
function p.infobox(frame)
     local origArgs
     local origArgs
     -- Si se llama a través de #invoke, utilice los argumentos pasados ​​a la plantilla de invocación.
     -- If called via #invoke, use the args passed into the invoking template.
     -- De lo contrario, para fines de prueba, asumen args que se pasan directamente.
     -- Otherwise, for testing purposes, assume args are being passed directly in.
     if frame == mw.getCurrentFrame() then
     if frame == mw.getCurrentFrame() then
         origArgs = frame:getParent().args
         origArgs = frame:getParent().args
Línea 243: Línea 243:
     end
     end
   
   
     -- ParserFunctions considera que una cadena vacía es falsa, por lo que para preservar el anterior
     -- ParserFunctions considers the empty string to be false, so to preserve the previous
     -- comportamiento de {{Ficha}}, debe cambiar los argumentos vacíos a cero, por lo que Lua los considerará
     -- behavior of {{infobox}}, change any empty arguments to nil, so Lua will consider
     -- que son falsos también (excepto parámetros 'title cursiva', que especifica un comportamiento diferente
     -- them false too. (Except the 'italic title' param, which specifies different behavior
     -- dependiendo de si está ausente o vacío)
     -- depending on whether it's absent or empty)
     args = {}
     args = {}
     for k, v in pairs(origArgs) do
     for k, v in pairs(origArgs) do