Module:BibleQuote: Difference between revisions

From Seeds of the Word, the encyclopedia of the influence of the Gospel on culture
No edit summary
No edit summary
Line 32: Line 32:
function p._main( args )
function p._main( args )
if (in_table(args.version, VERSIONS_AVAILABLE)) then
if (in_table(args.version, VERSIONS_AVAILABLE)) then
return "<span class=&quot;bibleQuoteRef&quot; style=&quot;color:Blue;font-weight:bold;cursor:pointer;&quot;>{{{ref}}}</span><div data-ref=&quot;{{{ref}}}&quot; data-version=&quot;{{{version}}}&quot; class=&quot;BibleGetQuote&quot;></div>"
return "<span class=&quot;bibleQuoteRef&quot; style=&quot;color:Blue;font-weight:bold;cursor:pointer;&quot;>" .. args.ref .. "</span><div data-ref=&quot;" .. args.ref .. "&quot; data-version=&quot;" .. args.version .. "&quot; class=&quot;BibleGetQuote&quot;></div>"
else
else
return args.version .. " is not a valid version"
return args.version .. " is not a valid version"

Revision as of 15:53, September 4, 2020

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

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"
    return p._main(args)
end

function p._main( args )
	if (in_table(args.version, VERSIONS_AVAILABLE)) then
		return "<span class=&quot;bibleQuoteRef&quot; style=&quot;color:Blue;font-weight:bold;cursor:pointer;&quot;>" .. args.ref .. "</span><div data-ref=&quot;" .. args.ref .. "&quot; data-version=&quot;" .. args.version .. "&quot; class=&quot;BibleGetQuote&quot;></div>"
	else
		return args.version .. " is not a valid version"
	end
	
end
return p