Module:Listing: Difference between revisions

Jump to navigation Jump to search
Want an adless experience? Log in or Create an account.
be a little smarter about parsing transclusion args (still not handling named args, haven't needed those yet)
(strip {{{params|}}})
(be a little smarter about parsing transclusion args (still not handling named args, haven't needed those yet))
Line 27: Line 27:
   line = line:gsub( '{{{.-|}}}', '' ) -- can appear on listings that are transcluded into other listings, but are only relevant to those other listings
   line = line:gsub( '{{{.-|}}}', '' ) -- can appear on listings that are transcluded into other listings, but are only relevant to those other listings
   -- recurse on transclusion
   -- recurse on transclusion
   local transcludedTitle, args = line:match( '^{{:(.-)|(.-)}}$' )
   local transclusion = line:match( '^{{:(.-)}}$' )
   if transcludedTitle then
   if transclusion then
     local transcludedContent = mw.text.killMarkers( mw.getCurrentFrame():expandTemplate{ title = ':' .. transcludedTitle, args = { [1] = args } } )
    local transclusionParts = mw.text.split( transclusion, '|' )
    local transcludedTitle = table.remove( transclusionParts, 1 ) -- remainder is treated as anonymous (numbered) args - TODO handle named args
     local transcludedContent = mw.text.killMarkers( mw.getCurrentFrame():expandTemplate{ title = ':' .. transcludedTitle, args = transclusionParts } )
     for transcludedLine in gsplit( transcludedContent, '\n' ) do
     for transcludedLine in gsplit( transcludedContent, '\n' ) do
       currentSection = handleLine( transcludedLine, currentSection )
       currentSection = handleLine( transcludedLine, currentSection )

Navigation menu