Jump to content

Module:IncrementParams

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Amadalvarez (talk | contribs) at 17:24, 16 July 2019. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

-- STEP 1: Click on the "edit" tab at the top of the page to edit this module.

-- STEP 2: if you want to increment by a number other than 1, put that number below, after the equals sign. 
local increment = 180

-- STEP 3: Replace the example template text with the template text that you wish to increment.
local templatetext = [==========[
| label422 = {{GetLabelFix|P137|lang={{{lang|}}} }}
|  data422 = {{{gestor|}}}
| label423 = {{GetLabelFix|Q3558349|lang={{{lang|}}} }} 
|  data423 = {{{president|}}}
| label424 = {{#ifeq:{{{president|}}}|{{{executiu_cap|}}}|<!-- ja s'ha mostrat -->|{{GetLabelFix|Q484876|lang={{{lang|}}}}} }}
|  data424 = {{#ifeq:{{{president|}}}|{{{executiu_cap|}}}|<!-- ja s'ha mostrat -->|{{{executiu_cap|}}} }}
| label426 = {{GetLabelFix|P1075|lang={{{lang|}}} }}  
|  data426 = {{{rector|}}}
| label427 = {{GetLabelFix|Q723682|lang={{{lang|}}}}}
|  data427 = {{{dega|}}}
| label428 = {{GetLabelFix|P3975|lang={{{lang|}}}}}
|  data428 = {{{secretari|}}}
| label429 = {{GetLabelFix|P1037|lang={{{lang|}}}}}
|  data429 = {{{director|}}}
| label430 = {{if empty|  {{{etiqueta_lider1|}}}|{{GetLabelFix|Q1251441|lang={{{lang|}}}}}}}
|  data430 = {{{nom_lider1|}}}
| label431 =  {{{etiqueta_lider2|}}}
|  data431 =  {{{nom_lider2|}}}
| label432 =  {{{etiqueta_lider3|}}}
|  data432 =  {{{nom_lider3|}}}
| label433 =  {{{etiqueta_lider4|}}}
|  data433 =  {{{nom_lider4|}}}
| label435 = {{GetLabelFix|Q188628|lang={{{lang|}}} }} 
|  data435 = {{{consell_administracio|}}}
| label437 = {{GetLabelFix|P3342|lang={{{lang|}}} }} 
|  data437 = {{{persona_clau|}}}
| label439 = {{if empty |{{{etiqueta_destacats|}}} |{{GetLabelFix|T0058|lang={{{lang|}}} }}}}
|  data439 = {{{membres_destacats|}}}
| label440 = {{GetLabelFix|P2813|lang={{{lang|}}} }}
|  data440 = {{{organ_premsa|}}}
]==========]

-- STEP 4: Save this module.

-- STEP 5: You can now output the incremented text with the following code:
--                {{subst:#invoke:IncrementParams|main}}
-- Or you can simply copy and paste the text from this module's documentation.

-- STEP 6: Check the output! In rare cases this module might produce false positives.
-- For example, it will change the text "[[Some link|foo3=bar]]" to "[[Some link|foo4=bar]]".
-- You can use the "show changes" function in the edit window of the template you are editing
-- to find any false positives.

-- STEP 7: When you are finished, undo your changes to this page, so that the next person
-- won't be confused by seeing any non-default values. Thanks for using this module!

local p = {}
 
local function replace(prefix, num, suffix)
    return '|' .. prefix .. tostring(tonumber(num) + increment) .. suffix .. '='
end
 
function p.main(frame)
    -- Increment the template text.
    templatetext = mw.ustring.gsub(templatetext, '|(%s*%a?[%a_%-]-%s*)([1-9]%d*)(%s*[%a_%-]-%a?%s*)=', replace)
    -- Add pre tags and escape html etc. if the pre option is set.
    if frame and frame.args and frame.args.pre and frame.args.pre ~= '' then
        templatetext = mw.text.nowiki(templatetext)
        templatetext = '<pre style="white-space:-moz-pre-wrap; white-space:-pre-wrap; '
            .. 'white-space:-o-pre-wrap; white-space:pre-wrap; word-wrap:break-word;">' 
            .. templatetext .. '</pre>'
    end
    return templatetext
end
 
return p