Module:NavboxUpgraded: Difference between revisions

No edit summary
No edit summary
Line 246: Line 246:


local function add_navbox_styles()
local function add_navbox_styles()
     local styles = ''
     local html = mw.html.create()
    if type(cfg.templatestyles) == 'string' then
   
        styles = styles .. cfg.templatestyles
    -- Helper function to add a stylesheet link
    local function add_stylesheet(path)
        html:tag('link')
            :attr('rel', 'stylesheet')
            :attr('href', path)
            :attr('type', 'text/css')
     end
     end
     if type(cfg.hlist_templatestyles) == 'string' then
 
         styles = styles .. cfg.hlist_templatestyles
    -- Assuming cfg.templatestyles contains space-separated CSS file paths
     if type(cfg.templatestyles) == 'string' and cfg.templatestyles ~= '' then
         for stylePath in cfg.templatestyles:gmatch("[^%s]+") do
            add_stylesheet(stylePath)
        end
     end
     end
     if type(cfg.plainlist_templatestyles) == 'string' then
 
         styles = styles .. cfg.plainlist_templatestyles
     if type(cfg.hlist_templatestyles) == 'string' and cfg.hlist_templatestyles ~= '' then
         for stylePath in cfg.hlist_templatestyles:gmatch("[^%s]+") do
            add_stylesheet(stylePath)
        end
     end
     end
     return mw.html.create('style'):wikitext(styles):done()
 
     if type(cfg.plainlist_templatestyles) == 'string' and cfg.plainlist_templatestyles ~= '' then
        for stylePath in cfg.plainlist_templatestyles:gmatch("[^%s]+") do
            add_stylesheet(stylePath)
        end
    end
 
    return html:done()
end
end