More languages
More actions
m (oops, forgot to refactor code) |
m (adding parser function example for later testing) |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
function is_lib_work(s) | |||
return mw.getCurrentFrame():callParserFunction('#ifexist',"Library:" .. s,true) == "1" | |||
end | |||
function p.cite(frame) | function p.cite(frame) | ||
-- Parent frame to get parameters from template calls instead of from {{#invoke: ... | -- Parent frame to get parameters from template calls instead of from {{#invoke: ... | ||
local parentFrame = frame:getParent() | local parentFrame = frame:getParent() | ||
-- get arguments from "args" table pre-defined by MediaWiki/Scribunto | |||
local link = parentFrame.args.link | local link = parentFrame.args.link | ||
local author = parentFrame.args.author | local author = parentFrame.args.author | ||
error("error message") | -- error("error message") to send error messages | ||
-- mw.log(mw.getCurrentFrame():callParserFunction('#dpl',"shownamespace=false","titleregexp=Vladimir Lenin/[^/]+$","replaceintitle=/Vladimir Lenin\//,","format=,%PAGE%\\n","namespace=Library")) | |||
end | end | ||
return p | return p |
Revision as of 00:08, 7 October 2024
local p = {}
function is_lib_work(s)
return mw.getCurrentFrame():callParserFunction('#ifexist',"Library:" .. s,true) == "1"
end
function p.cite(frame)
-- Parent frame to get parameters from template calls instead of from {{#invoke: ...
local parentFrame = frame:getParent()
-- get arguments from "args" table pre-defined by MediaWiki/Scribunto
local link = parentFrame.args.link
local author = parentFrame.args.author
-- error("error message") to send error messages
-- mw.log(mw.getCurrentFrame():callParserFunction('#dpl',"shownamespace=false","titleregexp=Vladimir Lenin/[^/]+$","replaceintitle=/Vladimir Lenin\//,","format=,%PAGE%\\n","namespace=Library"))
end
return p