Module
TemplateSource
From Dogcraft Wiki
mNo edit summary Tag: Reverted |
mNo edit summary Tag: Manual revert |
||
| Line 3: | Line 3: | ||
function p.test(frame) | function p.test(frame) | ||
-- source = frame:expandTemplate{ title = 'Templates Nav', args = {} } | -- source = frame:expandTemplate{ title = 'Templates Nav', args = {} } | ||
pageContent = mw.title.new( 'Template: | pageContent = mw.title.new( 'Template:Tutorial' ) | ||
return mw.text.nowiki( pageContent:getContent() ) | return mw.text.nowiki( pageContent:getContent() ) | ||
end | end | ||
return p | return p | ||
Revision as of 19:22, 31 January 2026
Meant to be used with the {{Template source}} template. Returns the plaintext contents of a template. Obeys the mostly the same behaviours as transclusion would, respects <onlyinclude>, <includeonly>, and <noinclude> tags. This module is primarily meant to be used as input to <syntaxhighlight>, which doesn't handle some tags (like <templatestyles> or <categorytree>) correctly.
Example
The source of the {{Pagetabs}} template, wrapped in a <syntaxhighlight> tag.
{{#tag:syntaxhighlight|{{#invoke:TemplateSource|templateSource|Template:Pagetabs}}|lang=html|line=1}} generates:
<strong class="error"><span class="scribunto-error" id="mw-scribunto-error-0">Script error: The function "templateSource" does not exist.</span></strong>
This page was last modified on 31 January 2026, at 19:22. (2 days ago)