“模块:Ship Specs”的版本间的差异
来自星际公民宇宙百科
小 |
|||
第4行: | 第4行: | ||
local specs = mw.text.jsonDecode(json) | local specs = mw.text.jsonDecode(json) | ||
mw.log(#specs) | mw.log(#specs) | ||
− | local | + | local h_table = mw.html.create('table'):addClass('ship-specs-table') |
− | |||
if specs["Name"] then | if specs["Name"] then | ||
− | + | h_table:tag('tr'):addClass('ship-specs-name'):tag('td'):attr({ width="100%", colspan="2" }):tag('b'):wikitext(specs["Name"]) | |
− | |||
− | |||
end | end | ||
if specs["Image"] then | if specs["Image"] then | ||
− | + | h_table:tag('tr'):addClass('ship-specs-image'):tag('td'):attr({ width="100%", colspan="2" }):wikitext(specs["Image"]) | |
− | |||
− | |||
end | end | ||
− | return tostring( | + | return tostring(h_table) |
end | end | ||
2015年10月4日 (日) 20:36的版本
此模块的文档可以在模块:Ship Specs/doc创建
local p = {}
function p.text( json )
local specs = mw.text.jsonDecode(json)
mw.log(#specs)
local h_table = mw.html.create('table'):addClass('ship-specs-table')
if specs["Name"] then
h_table:tag('tr'):addClass('ship-specs-name'):tag('td'):attr({ width="100%", colspan="2" }):tag('b'):wikitext(specs["Name"])
end
if specs["Image"] then
h_table:tag('tr'):addClass('ship-specs-image'):tag('td'):attr({ width="100%", colspan="2" }):wikitext(specs["Image"])
end
return tostring(h_table)
end
function p.main( frame )
return p.text(frame.args[1])
end
return p