Jump to content
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
Created page with "local p = {} -- Helper function to trim whitespace from a string local function trim(s) return s:match('^%s*(.-)%s*$') end -- Main function to transclude pages function p.transclude(frame) local input = frame.args[1] or '' local output = {} -- Split input into lines for line in input:gmatch('[^\r\n]+') do -- Trim whitespace and add transclusion syntax local page = trim(line) if page ~= '' then table.insert(ou..."
 
No edit summary
 
(17 intermediate revisions by the same user not shown)
Line 1: Line 1:
local p = {}
local p = {}


-- Helper function to trim whitespace from a string
local function trim(s)
    return s:match('^%s*(.-)%s*$')
end
-- Main function to transclude pages
function p.transclude(frame)
function p.transclude(frame)
     local input = frame.args[1] or ''
    -- Get and preprocess the input
     local output = {}
     local raw_input = frame.args[1] or ''
     local processed_input = 'yoggle' .. raw_input:gsub('E', 's') .. 'yoggle'
      
      
     -- Split input into lines
     -- Debug output
     for line in input:gmatch('[^\r\n]+') do
     return string.format(
        -- Trim whitespace and add transclusion syntax
        "Raw input:\n<pre>%s</pre>\n\nProcessed input:\n<pre>%s</pre>",
        local page = trim(line)
         raw_input,
        if page ~= '' then
        processed_input
            table.insert(output, string.format('{{%s}}', page))
     )
         end
    end
   
    -- Join all transclusions with newlines
    return table.concat(output, '\n')
end
 
-- Function to handle direct template calls
function p.transcludeFromTemplate(frame)
     local parent = frame:getParent()
    return p.transclude(parent)
end
end


return p
return p

Latest revision as of 11:53, 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 = 'yoggle' .. raw_input:gsub('E', 's') .. 'yoggle'
    
    -- 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