Module:HeroData: Difference between revisions

Jump to navigation Jump to search
Sur (talk | contribs)
m call_lang removed
Sur (talk | contribs)
m Infobox_hero > User:Sur; template vars to snake case
Line 100: Line 100:
     local postfix
     local postfix
      
      
     local templateArgs = {}
     local template_args = {}
      
      
     -- Iterate attribute categories
     -- Iterate attribute categories
Line 128: Line 128:
postfix = lang_module.call_lang(postfix)
postfix = lang_module.call_lang(postfix)
end
end
template_args[stat_name] = stat_value .. postfix
end
end
Line 136: Line 138:
end
end
   
    for stat_name, stat_value in pairs(hero_data) do
        if (type(stat_value) ~= "table") then  -- skips complex nested tables
            templateArgs[stat_name] = stat_value
        end
    end
      
      
     -- Use expandTemplate to evaluate the Infobox_hero template
     -- Use expandTemplate to evaluate the Infobox_hero template
     local templateTitle = mw.title.new("Template:Infobox_hero")
     local template_title = mw.title.new("User:Sur")
     local expandedTemplate = mw.getCurrentFrame():expandTemplate{ title = templateTitle, args = templateArgs }
     local expanded_template = mw.getCurrentFrame():expandTemplate{ title = template_title, args = template_args }
      
      
     return expandedTemplate
     return expanded_template
end
end