Module:Datalist: Difference between revisions

From Tsadra Foundation Advanced Contemplative Scholarships
(by SublimeText.Mediawiker)
(by SublimeText.Mediawiker)
 
(One intermediate revision by the same user not shown)
Line 6: Line 6:


     local output = mw.html.create( 'datalist' )
     local output = mw.html.create( 'datalist' )
     output:attr( 'id', pargs[1] )
     output
        :attr( 'id', pargs[1] )


     for value in string.gmatch(pargs[2], "([^,]+)") do
     for value in string.gmatch(pargs[2], "([^,]+)") do
         output = output .. '<option value="' .. value .. '"></option>'
         output
            :tag( 'option' )
                :attr( 'value', value )
     end
     end


    output = output .. '</datalist>'
     return output
 
     return tostring( output )


end
end


return p
return p

Latest revision as of 09:37, 29 April 2024

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

local p = {}

function p.datalist(frame)

    local pargs = frame:getParent().args

    local output = mw.html.create( 'datalist' )
    output
        :attr( 'id', pargs[1] )

    for value in string.gmatch(pargs[2], "([^,]+)") do
        output
            :tag( 'option' )
                :attr( 'value', value )
    end

    return output

end

return p