Module:NoteTransclude
Jump to navigation
Jump to search
Documentation for this module may be created at Module:NoteTransclude/doc
local p = {}
local function getNoteContent(page, section, field)
local content = mw.title.new(page):getContent()
if not content then
return "Error: Page not found"
end
local sectionContent = mw.ustring.match(content, "==" .. section .. "==%s*(.-)%s*==")
if not sectionContent then
return "Error: Section not found"
end
local noteContent = mw.ustring.match(sectionContent, "{{Note.-|%s*" .. field .. "%s*=%s*(.-)%s*}}")
if not noteContent then
return "Error: Field not found"
end
return noteContent
end
function p.transclude(frame)
local args = frame:getParent().args
local page = args[1]
local section = args[2]
local field = args[3]
if not (page and section and field) then
return "Error: Missing parameters. Usage: {{NoteTransclude|Page|Section|Field}}"
end
return getNoteContent(page, section, field)
end
return p