Module:CRTGallery: Difference between revisions

Arclight changed the content model of the page Module:CRTGallery from "wikitext" to "Scribunto module"
Fix delimiter splitting bug — use mw.text.split with plain match instead of gmatch character class (via update-page on MediaWiki MCP Server)
Line 8: Line 8:


     -- Query all "Has images" values stored by {{CRT model}} on this page
     -- Query all "Has images" values stored by {{CRT model}} on this page
    local delim = "~!~"
     local query = string.format(
     local query = string.format(
         '{{#ask:[[%s]]|?Has images|mainlabel=-|headers=hide|link=none|sep=<DELIM>|limit=50}}',
         '{{#ask:[[%s]]|?Has images|mainlabel=-|headers=hide|link=none|sep=%s|limit=50}}',
         pageName
         pageName, delim
     )
     )
     local result = frame:preprocess(query)
     local result = frame:preprocess(query)
Line 18: Line 19:
     end
     end


     -- Split on delimiter; each value is a File: title
     -- Split on delimiter using plain string match
    local parts = mw.text.split(result, delim, true)
     local lines = {}
     local lines = {}
     for part in result:gmatch("([^<DELIM>]+)") do
     for _, part in ipairs(parts) do
         local trimmed = mw.text.trim(part)
         local trimmed = mw.text.trim(part)
         if trimmed ~= "" then
         if trimmed ~= "" then
MediaWiki Appliance - Powered by TurnKey Linux