Module:TemplateHelpers: Difference between revisions

// via Wikitext Extension for VSCode
// via Wikitext Extension for VSCode
Line 6: Line 6:


local p = {}
local p = {}
--------------------------------------------------------------------------------
-- Constants
--------------------------------------------------------------------------------
-- This constant defines the how the strings for "label" are rendered in HTML
local FIELD_FORMAT = "|-\n| '''%s'''\n| %s"


-- Dependencies
-- Dependencies
Line 312: Line 319:
                     outIndex = outIndex + 1
                     outIndex = outIndex + 1
                 elseif processedValue ~= nil and processedValue ~= false then
                 elseif processedValue ~= nil and processedValue ~= false then
                     -- Standard field rendering
                     -- Standard field rendering with processor
                     out[outIndex] = string.format("|-\n| '''%s''':\n| %s", field.label, processedValue)
                     out[outIndex] = string.format(FIELD_FORMAT, field.label, processedValue)
                     outIndex = outIndex + 1
                     outIndex = outIndex + 1
                 end
                 end
             else
             else
                 -- Standard field rendering without processor
                 -- Standard field rendering without processor
                 out[outIndex] = string.format("|-\n| '''%s''':\n| %s", field.label, value)
                 out[outIndex] = string.format(FIELD_FORMAT, field.label, value)
                 outIndex = outIndex + 1
                 outIndex = outIndex + 1
             end
             end