Wiki source code of Velocity Code Style
Last modified by Simon Urli on 2023/11/14 15:37
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | Velocity scripts must follow these rules: | ||
2 | * Use 2 spaces for indentation | ||
3 | * Use single quotes for strings that don't need to be parsed/interpreted. This improves performances. | ||
4 | * Always capture the result of a method call in a variable to avoid side effects (things output to the result: what the method returns or unwanted empty lines). For example:((( | ||
5 | {{code language=="velocity"}} | ||
6 | #set ($discard = $someVar.someMethod()) | ||
7 | {{/code}} | ||
8 | ))) | ||
9 | * Internal macros that are not aiming at being exposed as API should always be prefixed with the character ##_##. API macros should always be properly documented with information on the parameters and a since information. This rule has been introduced with XWiki 15.10RC1 so old macros don't rely on it: they are considered by default as APIs but can be renamed after a vote. |