Module:HeroData/nav: Difference between revisionsGive feedback
Jump to navigation
Jump to search
Gammaton32 (talk | contribs) refactored hero list function for other functions to call for |
added no_redlinks variable |
||
| Line 3: | Line 3: | ||
local hero_release_module = require('Module:HeroData/release') | local hero_release_module = require('Module:HeroData/release') | ||
local lang_module = require('Module:Lang') | local lang_module = require('Module:Lang') | ||
local utilities = require('Module:Utilities') | |||
-- Shared helper function | -- Shared helper function | ||
| Line 132: | Line 133: | ||
-- for [[Template:Quotes Navbox]] etc. | -- for [[Template:Quotes Navbox]] etc. | ||
local utilities = require('Module:Utilities') | |||
p.get_hero_bulletpoints = function(frame) | p.get_hero_bulletpoints = function(frame) | ||
local subpage = frame.args['1'] | |||
local in_herolabs = frame.args['in_herolabs'] or 'false' | |||
local debug_mode = frame.args['debug_mode'] == 'true' | local debug_mode = frame.args['debug_mode'] == 'true' | ||
local no_redlinks = frame.args['no_redlinks'] == 'true' -- default: false | |||
local heroes = get_heroes(in_herolabs) | |||
local parts = {} | |||
local | for _, hero in ipairs(heroes) do | ||
local page_title = hero.name | |||
if subpage then | |||
page_title = hero.name .. '/' .. subpage | |||
end | |||
-- Skip redlinks entirely when enabled | |||
if not (no_redlinks and not utilities.page_exists(page_title)) then | |||
local item | |||
if subpage then | |||
item = '{{PageRef|' .. hero.name .. '|alt_link=' .. page_title .. '}}' | |||
else | |||
item = '{{HeroIcon|' .. hero.name .. '}}' | |||
end | |||
table.insert(parts, item) | |||
end | |||
end | end | ||
local | local ret = table.concat(parts, ' • ') | ||
if debug_mode then | if debug_mode then | ||
return ret | return ret | ||
else | else | ||
return frame:preprocess(ret) | return frame:preprocess(ret) | ||
end | end | ||