Module:TemplateStarter: Difference between revisions

// via Wikitext Extension for VSCode
Maintenance update // via Wikitext Extension for VSCode
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
-- Module:TemplateStarter
--[[
-- Generates configurable template structures for new pages using ConfigRepository
* Name: TemplateStarter
* Author: Mark W. Datysgeld
* Description: Generates configurable template structures for new pages using ConfigRepository with support for variants and placeholder replacement
* Notes: Template generation from ConfigRepository configs; support for campaign variants; placeholder replacement in boilerplate text; creator field management; caching of template lists; includes error handling and validation
]]


local p = {}
local p = {}
Line 148: Line 152:
      
      
     templateType = mw.text.trim(tostring(templateType))
     templateType = mw.text.trim(tostring(templateType))
   
    -- Handle "None" special case
    if templateType == "None" then
        return ""
    end
      
      
     -- Parse template to check if it's a variant
     -- Parse template to check if it's a variant
Line 228: Line 237:
     -- Sort the final combined list
     -- Sort the final combined list
     table.sort(templatesWithCampaigns)
     table.sort(templatesWithCampaigns)
   
    -- Add "None" option at the beginning
    table.insert(templatesWithCampaigns, 1, "None")
      
      
     return templatesWithCampaigns
     return templatesWithCampaigns
Line 234: Line 246:
-- Parse campaign template name to get base template and campaign info
-- Parse campaign template name to get base template and campaign info
function p.parseVariantTemplate(templateName)
function p.parseVariantTemplate(templateName)
     if not templateName or templateName == "" then
     if not templateName or templateName == "" or templateName == "None" then
         return nil
         return nil
     end
     end
Line 321: Line 333:
-- Get creator fields for a specific template type
-- Get creator fields for a specific template type
function p.getCreatorFields(templateType)
function p.getCreatorFields(templateType)
     if not templateType or templateType == "" then
     if not templateType or templateType == "" or templateType == "None" then
         return {}
         return {}
     end
     end