Module 1:
local p = {}
function p.main()
local title = mw.title.getCurrentTitle()
title.fragment = 'a fragment'
return 'The fragment is: ' .. title.fragment
end
return pModule 2:
local p = {}
function p.main()
local title = mw.title.getCurrentTitle()
return 'The fragment is: ' .. title.fragment
end
return pModule invocations:
{{#invoke:Module 1|main}}
{{#invoke:Module 2|main}}The fragment property persists across the two #invokes, giving the output:
The fragment is: a fragment The fragment is: a fragment
I've made example modules here and here, and an example invocation here.
This only happens for title objects fetched with mw.title.getCurrentTitle. Fragments don't persist across #invokes for title objects made with mw.title.new, even if the title is for the current page.