Module:SB: Difference between revisions

From Teopedia
No edit summary
No edit summary
Line 11: Line 11:
local iNum = frame.args['item']
local iNum = frame.args['item']
if #vNum == 1 then
if tunumber(vNum) < 10 then
local vNum = 0 .. vNum
vNum = 0 .. vNum
end
end
if #iNum == 1 then
if tonumber(iNum) < 10 then
local iNum = 0 .. iNum
iNum = 0 .. iNum
end
end

Revision as of 10:50, 16 April 2021


Lua functions for HPB Scrapbooks.

Functions

item_id

Called from {{HPB-SB-item}} for setting semantic property [[HPB SB item ID]].

{{#invoke: SB | item_id | volume=1 | page=17 | item=4 }}

footnote

Called from {{HPB-SB-item}}.

{{#invoke: SB | footnote 
 | title=
 | author=
 | author_signed=
 | type= 
 | source_title=
 | source_details=
 | notes=
 | archivist_notes=
 | language = 
 | translator = 
}}


Debug example

=p.item_id{args={["volume"]="1",["page"]="17.2",["item"]="3"}}

Module code


local sb = {} -- functions package for HPB Scrapbooks

function sb.item_id( frame )
	local id = frame.args['volume'] .. '-' .. frame.args['page'] .. '-' .. frame.args['item']
    return id
end

function sb.item_id2( frame )
	local vNum = frame.args['volume']
	local pNum = frame.args['page']
	local iNum = frame.args['item']
	
	if tunumber(vNum) < 10 then
		vNum = 0 .. vNum
	end
	
	if tonumber(iNum) < 10 then
		iNum = 0 .. iNum
	end
	

	local id = vNum .. '-' .. pNum .. '-' .. iNum
    return id
end


return sb