Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Transclude: Difference between revisions

From Teriock
Content deleted Content added
No edit summary
Tag: Reverted
No edit summary
Tag: Manual revert
Line 3: Line 3:
function p.transclude(frame)
function p.transclude(frame)
-- Get and preprocess the input
-- Get and preprocess the input
local input = frame:preprocess(frame.args[1] or '')
local raw_input = frame.args[1] or ''
local output = {}
local processed_input = frame:preprocess(raw_input)
-- Debug output
-- Handle multiple consecutive newlines and spaces
return string.format(
for line in input:gmatch("[^%s]+") do
"Raw input:\n<pre>%s</pre>\n\nProcessed input:\n<pre>%s</pre>",
-- Trim any remaining whitespace
raw_input,
line = line:match("^%s*(.-)%s*$")
if line ~= "" then
processed_input
)
table.insert(output, string.format("{{%s}}", line))
end
end
-- Join with single newlines
return table.concat(output, "\n")
end
end



Revision as of 11:49, 14 January 2025

Documentation for this module may be created at Module:Transclude/doc

local p = {}

function p.transclude(frame)
    -- Get and preprocess the input
    local raw_input = frame.args[1] or ''
    local processed_input = frame:preprocess(raw_input)
    
    -- Debug output
    return string.format(
        "Raw input:\n<pre>%s</pre>\n\nProcessed input:\n<pre>%s</pre>",
        raw_input,
        processed_input
    )
end

return p