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