Module:T-TLD: Difference between revisions

// via Wikitext Extension for VSCode
// via Wikitext Extension for VSCode
Line 96: Line 96:
end
end


-- === Block Overrides ===
template.config.blocks = template.config.blocks or {}
template.config.blocks.title = {
    feature = 'title',
    render = function(template, args)
        return Blueprint.protectedExecute(
            template,
            'CustomBlock_title',
            function()
                local titleText = (args._type == 'ccTLD') and 'ccTLD' or 'gTLD'
                return TemplateHelpers.renderTitleBlock(
                    args,
                    'template-title template-title-tld',
                    titleText,
                    template.config.meta and template.config.meta.titleOptions or {}
                )
            end,
            '',
            args
        )
    end
}


-- === Field Processors ===
-- === Field Processors ===
Line 160: Line 138:
end)
end)


-- === Category Provider ===
Blueprint.registerCategoryProvider(template, function(template, args)
    local cats = {}
    local cond = template.config.categories and template.config.categories.conditional or {}
    if cond.rvc and ((args.RVC and args.RVC ~= "") or (args.PIC and args.PIC ~= "")) then
        table.insert(cats, cond.rvc)
    end
    if args._idnFlag and cond.idn then
        table.insert(cats, cond.idn)
    end
    if args._idnFlag and args._type == "ccTLD" and cond.idn_cctld then
        table.insert(cats, cond.idn_cctld)
    end
    -- Type mapping categories
    for _, cat in ipairs(getSemanticCategoryHelpers().addMappingCategories(args._type, template.config.mappings.tld_type) or {}) do
        table.insert(cats, cat)
    end
    -- Subtype mapping categories
    for _, cat in ipairs(getSemanticCategoryHelpers().addMappingCategories(args._type, template.config.mappings.tld_subtype) or {}) do
        table.insert(cats, cat)
    end
    return cats
end)


-- IDN detection preprocessor
-- IDN detection preprocessor