Modul:Test: Unterschied zwischen den Versionen

Aus STA Dokumentationsplattform
Zur Navigation springen Zur Suche springen
imported>Juergen.Kett
imported>Juergen.Kett
Zeile 7: Zeile 7:
 
  local qid = frame.args.qid
 
  local qid = frame.args.qid
 
  label = mw.wikibase.getLabel(pid)
 
  label = mw.wikibase.getLabel(pid)
  -- entity = mw.wikibase.getEntity(qid)  
+
  entity = mw.wikibase.getEntity(qid)  
  -- statements = entity.getAllStatements(pid)
+
  statements = mw.wikibase.entity.getAllStatements(pid)
 
  return label .. ", QID: " .. qid
 
  return label .. ", QID: " .. qid
 
end
 
end

Version vom 27. Mai 2020, 14:17 Uhr

Die Dokumentation für dieses Modul kann unter Modul:Test/Doku erstellt werden

-- Das Modul enthält einige Testfunktionen, um das Skripting mit Lua zu erproben

local p = {}; 

p.getStatement = function (frame) 
 local pid = frame.args.pid
 local qid = frame.args.qid
 label = mw.wikibase.getLabel(pid)
 entity = mw.wikibase.getEntity(qid) 
 statements = mw.wikibase.entity.getAllStatements(pid)
 return label .. ", QID: " .. qid
end

p.getLabel = function (frame)
 local id = frame.args.id
 local label = mw.wikibase.getLabel(id)
 return "ID: " .. id .. ", Label: " .. label
end

p.hello = function( frame ) 
  local str = "Hello World!" 
  return str
end

function p.hello_to(frame)
  local name = frame.args[1]
  return "Hello, " .. name .. "!" 
end

function p.count_fruit(frame)
	local num_bananas = frame.args.bananas 
	local num_apples = frame.args.apples  
										   
	return 'I have ' .. num_bananas .. ' bananas and ' .. num_apples .. ' apples'							
end

return p