Manual:Coding conventions/Lua/fr

Espace blanc

 * 1) Utiliser tab pour l'indentation. Auparavant, nous utilisions 4 espaces, mais nous sommes passés à tab après que le comportement par défaut de l'éditeur de code de Wikipedia a changé.
 * 2) Essayez de limiter la longueur des lignes, pour que des gens avec des écrans moins larges puissent lire le code plus aisément.
 * 3) Avoid extraneous whitespace when calling a function or subscripting an array or dictionary. No spaces should be used immediately before or inside a bracketing character (  and their matches).

Control flow
Putting multiple statements on one line is discouraged, unless the expression is very short. Try to avoid this with multi-clause statements, too.

If a single line would be too long, you can split a large statement over multiple lines with a hanging indent that aligns with the opening delimiter. For  statements, the conditions should be placed on the next line.

Naming conventions
Define the entry method as simply unpacking the parameters from the frame, and then passing those through a function with the same name prefixed with a single underscore. This can be disregarded if the function is only useful from wikitext, or if it needs a frame for something other than its arguments.

In the standard library, function names consisting of multiple words are simply put together (e.g. ). Note that camelCase is the preferred way to name functions, in order to avoid potential garden-path function names.

Highlighting Lua code
Outside of a module (like on talkpages), code highlighting can be added using the &lt;syntaxhighlight> tag with the attribute :

Produces: