Help:Scribunto
Debug console testing example
For a hypothetical module titled Module:Example with one function named test_function:
-- Create an empty frame local f = mw.getCurrentFrame() -- Set arguments for the frame -- This is equivalent to {{#invoke:Example|Absalom|Corentyn}} f.args = { 'Absalom', 'Corentyn' } -- For named arguments, like {{#invoke:Example|name=Absalom}}, use: -- f.args = { name = 'Absalom' } -- p is Scribunto's default result -- Display the result of the function using the test frame = p.test_function(f)
The mw.log()
and mw.logObject()
functions output strings and dumped objects, respectively, to the console before the return value, but only if the module can run without any errors—even if the log call occurs before the error.