Module:BibleQuote

Revision as of 17:41, September 4, 2020 by Johnrdorazio (talk | contribs)

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

require("fs")

local getArgs = require('Module:Arguments').getArgs
local VERSIONS_AVAILABLE = {
	"NABRE",
	"NVBSE",
	"LUZZI",
	"CEI2008"
}

-- let's keep the needle in a haystack ordering typical of PHP
local function in_table (val, tab)
    for index, value in ipairs(tab) do
        if value == val then
            return true
        end
    end

    return false
end

local p = {} --p stands for package

function p.main( frame )
    local args = getArgs(frame, {
    	--we will only consider arguments that are passed by the template itself in the invoke
    	frameOnly = true
    })
    -- let's make sure defaults are set
    args.version = args.version or "NABRE"
    args.ref = args.ref or "John 3:16"
    return p._main(args)
end

function p._main( args )
	if (in_table(args.version, VERSIONS_AVAILABLE)) then
		return "<span class=\"bibleQuoteRef\" style=\"color:Blue;font-weight:bold;cursor:pointer;\">" .. args.ref .. "</span><div data-ref=\"" .. args.ref .. "\" data-version=\"" .. args.version .. "\" class=\"bibleGetQuote\"></div>"
	else
		return "<span style=\"color:red;\">\"" .. args.version .. "\" is not a valid version supported by the BibleGet project</span>"
	end
	
end
return p