Module

TemplateSource

From Dogcraft Wiki

No edit summary
(Created page with "local p = {} function p.templateSource(frame) frame:expandTemplate{ title = 'tutorial', args = {} } end return p")
Line 1: Line 1:
local p = {}
local p = {}


function p.test(frame)
function p.templateSource(frame)
name = nil
frame:expandTemplate{ title = 'tutorial', args = {} }
if frame.args.name then
name = frame.args.name
end
return (name or "no")
end
end


return p
return p

Revision as of 18:20, 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:


local p = {}

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

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