Module:T-CountryHub: Difference between revisions
// via Wikitext Extension for VSCode |
// via Wikitext Extension for VSCode Tag: Reverted |
||
| Line 84: | Line 84: | ||
end | end | ||
-- generateProcessedBrowseLink: Constructs and preprocesses a MediaWiki link for browsing data. | |||
local function generateProcessedBrowseLink(template, browseType, browseQueryParam, linkTextPattern, country) | |||
-- Use the centralized LinkParser function to create the fullurl wikitext | |||
local browseLinkWikitext = LinkParser.createFullUrlWikitext('Special:BrowseData/' .. browseType, { | |||
[browseQueryParam] = country | |||
}) | |||
-- local browseLinkString = string.format( | -- Create the full link with display text | ||
local browseLinkString = string.format( | |||
'[%s %s →]', | |||
browseLinkWikitext, | |||
string.format(linkTextPattern, country) -- Use original country name for display | |||
) | |||
if template.current_frame and template.current_frame.preprocess then | |||
local ok, result = pcall(function() return template.current_frame:preprocess(browseLinkString) end) | |||
if ok then | |||
return result | |||
else | |||
return browseLinkString -- Fallback on preprocess error | |||
end | |||
end | |||
return browseLinkString -- Fallback if no frame or preprocess | |||
end | |||
local errorContext = ErrorHandling.createContext("T-CountryHub") | local errorContext = ErrorHandling.createContext("T-CountryHub") | ||