Nhảy chuyển tới nội dung

Mô tổ:Unsubst2

被永久保护的模块
Duy cơ bách khoa, tự do bách khoa toàn thư
文档图示Mô khối hồ sơ[Sáng tạo]
localp={}
localmerror=require("Module:Error")
localspecialParams={
['$N']='template name',-- Deprecated, but keeping until it is removed from transcluding templates
['$B']='template content',
}

p['']=function(frame)
ifmw.isSubsting()then
---- substing
-- Combine passed args with passed defaults
localargs={}
fork,vinpairs(frame.args)do
ifnotspecialParams[k]then
ifv=='__DATE__'then
v=mw.getContentLanguage():formatDate('Y năm n nguyệt ')
end
ifv=='__TIME__'or'__time__'then
v=mw.getContentLanguage():formatDate('c')
end
args[k]=v
end
end
fork,vinpairs(frame:getParent().args)do
args[k]=v
end

-- Build an equivalent template invocation
-- First, find the title to use
localtitleobj=mw.title.new(frame:getParent():getTitle())
localtitle
iftitleobj.namespace==10then-- NS_TEMPLATE
title=titleobj.text
elseiftitleobj.namespace==0then-- NS_MAIN
title=':'..titleobj.text
else
title=titleobj.prefixedText
end

-- Build the invocation body with numbered args first, then named
localret='{{'..title
fork,vinipairs(args)do
ifstring.find(v,'=',1,true)then
-- likely something like 1=foo=bar, we need to do it as a named arg
break
end
ret=ret..'|'..v
args[k]=nil
end
fork,vinpairs(args)do
ret=ret..'|'..k..'='..v
end

returnret..'}}'
else
---- Not substing
-- Just return the "body"
returnframe.args['$B']..(frame.args['$N']andframe:getParent():getTitle()==mw.title.getCurrentTitle().prefixedTextand'[[Category: Sử dụng $N Module:Unsubst thuyên chuyển ]]'or'')
end
end

returnp