Module:template parser: Difference between revisions

m 1 revision imported
m 1 revision imported
 
(One intermediate revision by one other user not shown)
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
-- the template won't fail, but the redirect does not get resolved (i.e.
-- Resolve any redirects. If the redirect target is an interwiki link,
-- the redirect page itself gets transcluded, so the template name
-- the template won't fail, but the redirect does not get resolved (i.e.
-- should not be normalized to the target).
-- the redirect page itself gets transcluded, so the template name
local redirect = redirect_target(title, force_transclusion)
-- should not be normalized to the target).
if redirect and not redirect.isExternal then
local redirect = redirect_target(title, force_transclusion)
title = redirect
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
-- function count by forcing transclusion instead. This should only be used
-- instead. This should only be used when there is a real risk that the expensive parser function limit of
-- 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)