“模块:Ship Specs”的版本间的差异
来自星际公民宇宙百科
小 |
|||
第6行: | 第6行: | ||
function p.dumpObject( frame ) | function p.dumpObject( frame ) | ||
− | return mw.dumpObject( | + | local json = (string.gsub(frame.args[1], "<[/]?pre>", "")) |
+ | return tostring(mw.dumpObject( json )) | ||
end | end | ||
2015年10月5日 (一) 08:17的版本
此模块的文档可以在模块:Ship Specs/doc创建
local p = {}
function p.unstripNoWiki( frame )
return tostring(mw.text.unstripNoWiki(frame.args[1]))
end
function p.dumpObject( frame )
local json = (string.gsub(frame.args[1], "<[/]?pre>", ""))
return tostring(mw.dumpObject( json ))
end
function p.text( json )
json = mw.text.decode(json)
json = (string.gsub(json, "<[/]?pre>", ""))
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