Module:MasonryLayout: Difference between revisions
// via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode |
||
| Line 637: | Line 637: | ||
-- Render cards in this column | -- Render cards in this column | ||
for j, card in ipairs(columnCards) do | for j, card in ipairs(columnCards) do | ||
cardHtml[j] = string.format( | -- Check if content already has the card wrapper | ||
-- (This handles cases where content might be pre-wrapped) | |||
local content = card.content or EMPTY_STRING | |||
local needsWrapper = true | |||
-- Simple check: if content already has our card class, don't double-wrap | |||
if content:find('class="[^"]*' .. cardClass .. '[^"]*"') then | |||
needsWrapper = false | |||
end | |||
if needsWrapper then | |||
cardHtml[j] = string.format( | |||
'<div class="%s" data-card-id="%s">%s</div>', | |||
cardClass, | |||
card.id or 'unknown', | |||
content | |||
) | |||
else | |||
-- Content is already wrapped, just use it as-is | |||
cardHtml[j] = content | |||
end | |||
end | end | ||