Module:Calculator

Jump to navigation Jump to search

This module powers Template:Calculator.

Dependencies[edit source]

[view] [edit] [history] [refresh]The above documentation is transcluded from Module:Calculator/doc.
local p = {}

function p.main( frame )
	local args = require( [[Module:ProcessArgs]] ).norm( frame:getParent().args )
    return p.createTag( args )
end

function p.createTag( args )
	local div = mw.html.create( 'div' )
	div
		:attr( 'class', 'mcw-calc searchaux' )
        :attr( 'data-type', args[1] )
        :attr( 'style', args['style'] )
		:wikitext( 'An interactive widget is being loaded. If this does not work for you, please reload the page or check if JavaScript is working or enabled.' )

    for k, v in pairs(args) do
        if k ~= 1 and k ~= 'style' then
            div:attr( 'data-' .. k, v )
        end
    end

	return tostring( div )
end

return p