Module:Template test case/data: Difference between revisions

    From Nonbinary Wiki
    (create data module to load from Module:Template test case)
     
    m (Jackmcbarn moved page Module:Template test cases/data to Module:Template test case/data without leaving a redirect: along with parent module)
    (No difference)

    Revision as of 22:41, 27 November 2014

    Documentation for this module may be created at Module:Template test case/data/doc

    -- This module processes configuration data for use in
    -- [[Module:Template test case]]. It is loaded from the main module with
    -- mw.loadData.
    
    local cfg = require('Module:Template test case/config')
    
    local function escapePattern(s)
    	s = s:gsub('%p', '%%%0')
    	return s
    end
    
    -- Escape config items that need to be used as patterns. Doing it here is more
    -- efficient, as mw.loadData saves them from having to be computed for every
    -- test case on a page.
    cfg.templateNameMagicWordPattern = escapePattern(cfg.templateNameMagicWord)
    cfg.sandboxSubpagePattern = '/' .. escapePattern(cfg.sandboxSubpage) .. '$'
    
    return cfg