Module:InfoboxHero: Difference between revisionsGive feedback
Jump to navigation
Jump to search
Create Lua implementation of the hero infobox, to replace the wikitext in Template:Infobox hero (with help from vergir-bot LLM) |
Fix parameter resolution for direct #invoke, and set DISPLAYTITLE via parser function instead of returning it as wikitext (with help from vergir-bot LLM) |
||
| Line 27: | Line 27: | ||
local util = require('Module:Utilities') | local util = require('Module:Utilities') | ||
local lang_module | local lang_module = require('Module:Lang') | ||
local dict_module | local dict_module = require('Module:Dictionary') | ||
local hero_module | local hero_module = require('Module:HeroData') | ||
-- Defined below the CONFIG block; declared here so config closures can see them. | -- Defined below the CONFIG block; declared here so config closures can see them. | ||
| Line 732: | Line 732: | ||
function p.render(frame) | function p.render(frame) | ||
local parent = frame:getParent() | local parent = frame:getParent() | ||
local | local invoke_args = frame.args | ||
local template_args = parent and parent.args or {} | |||
-- Missing parameters read as '' so callers never have to nil-check. | -- Missing parameters read as '' so callers never have to nil-check. | ||
local args = setmetatable({}, { __index = function(_, k) | local args = setmetatable({}, { __index = function(_, k) | ||
local value = invoke_args[k] | |||
if value == nil then value = template_args[k] end | |||
return value or '' | |||
end }) | |||
local hero_key = resolve_hero_key(args.key) | local hero_key = resolve_hero_key(args.key) | ||
| Line 776: | Line 781: | ||
render_information(ctx, tbl) | render_information(ctx, tbl) | ||
if mw.title.getCurrentTitle().nsText ~= 'Template' then | if mw.title.getCurrentTitle().nsText ~= 'Template' then | ||
frame:callParserFunction('DISPLAYTITLE', ctx.display_name) | |||
end | end | ||
return | return tostring(root) .. render_categories(ctx) | ||
end | end | ||
return p | return p | ||