Module:Inventory slot: Difference between revisions
mNo edit summary |
mw.html annoying treats attribute values as plain text, rather than HTML text which can have HTML entities in it, unlike the rest of MediaWiki and the web in general. Also fixed formatting only titles not working. |
||
Line 134: | Line 134: | ||
end | end | ||
plainTitle:gsub( '\', '\\' ):gsub( '&', '&' ) | if plainTitle == '' then | ||
plainTitle = name | |||
else | |||
plainTitle = plainTitle:gsub( '\', '\\' ):gsub( '&', '&' ) | |||
end | |||
elseif link then | elseif link then | ||
if img then | if img then | ||
Line 149: | Line 153: | ||
if img then | if img then | ||
-- & is re-escaped because mw.html treats attributes | |||
-- as plain text, but MediaWiki doesn't | |||
local escapedTitle = ( plainTitle or '' ):gsub( '&', '&' ) | |||
item:addClass( 'invslot-item-image' ) | item:addClass( 'invslot-item-image' ) | ||
:wikitext( '[[File:Grid ', img, '.png|32x32px|link=', link or '', '|', | :wikitext( '[[File:Grid ', img, '.png|32x32px|link=', link or '', '|', escapedTitle, ']]' ) | ||
else | else | ||
if not sprite then | if not sprite then | ||
Line 166: | Line 173: | ||
image = image, settings = 'InvSprite' | image = image, settings = 'InvSprite' | ||
} | } | ||
item: | item:node( image ) | ||
category = spriteCat | category = spriteCat | ||
end | end |