Module

TemplateSource

From Dogcraft Wiki

Revision as of 18:21, 31 January 2026 by Domino (talk | contribs)

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:

'"`UNIQ--templatestyles-0000000C-QINU`"'<div id="tutorial" style="display:flex; justify-content:center; align-items:center; margin:10px 0;">
<div style="border-bottom:3px solid #8b0024; background:#e9edef; padding:0.3em 1rem; text-align:center; min-width:50%; ">
<div style="font-size:20px; font-weight:bold;"><div style="color:gray; font-size:small; margin-bottom:-5px;">Tutorial</div>Title</div>
<div style="font-style:italic; font-size:14px; color:darkgray;"></div>
<div id="tutorial-nav" class="flex-mobile-wrap slim" style="display:flex; flex-direction:row; align-items:center; justify-content:space-between; text-align:center; padding-top:0.3em;">
<span style="font-weight:600; white-space:nowrap;">[[{{{previous}}}|<span class="mw-ui-button  " id="">« Previous</span>]]</span>
<div id="tutorial-chapters" style="flex-grow:1; margin:0 10px; font-size:85%; word-wrap:anywhere;"></div>
<span style="font-weight: 600; white-space:nowrap;">[[{{{next}}}|<span class="mw-ui-button mw-ui-progressive " id="">Next »</span>]]</span>
</div></div></div>

local p = {}

function p.templateSource(frame)
	return frame:expandTemplate{ title = 'tutorial', args = {} }
end

return p
This page was last modified on 31 January 2026, at 18:21. (2 days ago)