Lua templating/Tips and tricks

This page consists of tips and tricks on the creation/modding/debugging of lua templates.

Preview
The preview button allows one to see what the module will display before it is saved. It is a good idea always to work with two pages, one with the actual module being edited and one test page that invokes the module. Rather than refreshing the test page a simple preview will save time.

Incorrectly passed arguments
These can cause problems if they contain special characters such as "=". The result will be that the module may not correctly interpret the passed arguments if they are for example part of a URL string, e.g. "https://www.google.com.mz/search?q=lua+templating+tips+and+tricks "

Debugging console

 * Debugging functions using the console - One can debug functions written in the module text area using the debug console. To do this one merely needs to call the function, e.g. mw.log(p.helloworld("howdy")).
 * Console shows two types of errors - One of the error relates to a syntax problem in the console itself, and the other relates to errors in the module text area. Simply clicking enter will show one of the two.
 * Print debug output - Output can be printed to the console using "mw.log("test")".
 * Frame - The frame is simply "nil"(empty) using the debug console, as it generally obtains parameters from templates or calling pages.