Module:T-Event: Difference between revisions

// via Wikitext Extension for VSCode
// via Wikitext Extension for VSCode
Line 1: Line 1:
--Module:T-Event
--Module:T-Event
-- Renders the "Event" template for events, making use of ICANNWiki's "Template Blueprint Framework"
-- Makes use of ICANNWiki's "Template Blueprint Framework" to render the "Event" template


local p = {}
local p = {}
Line 58: Line 58:
-- ================================================================================
-- ================================================================================


-- Custom date-range processor: join start and ending if present
-- TEMPLATE-SPECIFIC CALLS AND CODE
template.config.processors = template.config.processors or {}
template.config.processors.start = function(value, args, template)
    local endDate = args['ending']
    if endDate and endDate ~= '' then
        return TemplateHelpers.formatDateRange(value, endDate, {outputMode="complete"})
    end
    return TemplateHelpers.normalizeDates(value)
end
template.config.processors.ending = function(value, args, template)
    return false
end


-- ELEMENT:NAVIGATION
-- ELEMENT:NAVIGATION
Line 83: Line 72:
     }
     }
end
end
-- CUSTOM DATE-RANGE PROCESSOR
-- In cases where there are both "start" and "ending" dates to the event, we join them into a single "Date" field, with the dates separated by a "–" (En dash)
template.config.processors = template.config.processors or {}
template.config.processors.start = function(value, args, template)
    local endDate = args['ending']
    if endDate and endDate ~= '' then
        return TemplateHelpers.formatDateRange(value, endDate, {outputMode="complete"})
    end
    return TemplateHelpers.normalizeDates(value)
end
template.config.processors.ending = function(value, args, template)
    return false
end
-- ================================================================================


-- ==================== Preprocessors ====================
-- ==================== Preprocessors ====================
Line 90: Line 95:


-- ==================== Main Render Function ====================
-- ==================== Main Render Function ====================
-- Blueprint default: Render
function p.render(frame)
function p.render(frame)
     return ErrorHandling.protect(
     return ErrorHandling.protect(