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 15:12, 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 = 150

-- STEP 3: Replace the example template text with the template text that you wish to increment.
local templatetext = [==========[
<!-- Separador per textos fundacionals: si s'especifica posa header56,
                                        si no, posa línia incolora (data57) -->
| header68 = {{#if: {{{establerta_nom1|}}}{{{establerta_nom2|}}}{{{establerta_nom3|}}}
                    {{{establerta_nom4|}}}{{{establerta_nom5|}}}  
                  | {{#if:{{{etiqueta_establiment|}}} | {{{etiqueta_establiment|}}} }} }}
| data69  = {{#if: {{{establerta_nom1|}}}{{{establerta_nom2|}}}{{{establerta_nom3|}}}
                    {{{establerta_nom4|}}}{{{establerta_nom5|}}}  
                  | {{#if:{{{etiqueta_establiment|}}}|<!--sense text específic -->|<hr> }} }}
| label70 = {{nowrap|{{{establerta_data1|}}} }}
| data70  =  {{{establerta_nom1|}}}
| label72 = {{nowrap|{{{establerta_data2|}}} }}
| data72  = {{{establerta_nom2|}}}    
| label74 = {{nowrap|{{{establerta_data3|}}} }}
| data74  = {{{establerta_nom3|}}}
| label76 = {{nowrap|{{{establerta_data4|}}} }} 
| data76  = {{{establerta_nom4|}}}
| label78 = {{nowrap|{{{establerta_data5|}}} }} 
| data78  = {{{establerta_nom5|}}}

<!--  Paràmetres comodí bloc "història"-->
|  data79 = {{{bloc_historia_especial|}}}
| label80 = {{{etiqueta_historia1|}}}
|  data80 = {{{nom_historia1|}}}
| label81 = {{{etiqueta_historia2|}}}
|  data81 = {{{nom_historia2|}}}
| label82 = {{{etiqueta_historia3|}}}
|  data82 = {{{nom_historia3|}}}
| label83 = {{{etiqueta_historia4|}}}
|  data83 = {{{nom_historia4|}}}
| label84 = {{{etiqueta_historia5|}}}
|  data84 = {{{nom_historia5|}}}
]==========]

-- 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