Module:template parser: Difference between revisions
m 1 revision imported |
add a flag to allow redirect checking to be bypassed, for use on Module:headword/pages (on mainspace pages, we check only for #DEFAULTSORT: and #DISPLAYTITLE: builtins, which AFAIK can't be redirected to) |
||
| Line 405: | Line 405: | ||
return nil | return nil | ||
end | end | ||
-- Resolve any redirects. If the redirect target is an interwiki link, | if force_transclusion ~= "no_redirect" then | ||
-- Resolve any redirects. If the redirect target is an interwiki link, | |||
-- the template won't fail, but the redirect does not get resolved (i.e. | |||
-- the redirect page itself gets transcluded, so the template name | |||
-- should not be normalized to the target). | |||
local redirect = redirect_target(title, force_transclusion) | |||
if redirect and not redirect.isExternal then | |||
title = redirect | |||
end | |||
end | end | ||
-- If `fragment` is not true, unset it from the title object to prevent | -- If `fragment` is not true, unset it from the title object to prevent | ||
| Line 422: | Line 424: | ||
end | end | ||
-- Note: force_transclusion avoids incrementing the expensive parser | -- Note: `force_transclusion` avoids incrementing the expensive parser function count by forcing transclusion | ||
-- instead. This should only be used when there is a real risk that the expensive parser function limit of | |||
-- 500 will be hit. If `force_transclusion` has the value "no_redirect", redirect checking is turned off | |||
-- 500 will be hit. | -- entirely. This should only be used in very limited circumstances when it is otherwise impossible to avoid | ||
-- hitting the expensive parser limit and we are willing to handle the possible redirects ourselves. | |||
local function process_name(self, frame_args, force_transclusion) | local function process_name(self, frame_args, force_transclusion) | ||
local name = expand(self[1], frame_args) | local name = expand(self[1], frame_args) | ||