These are syntax and style conventions extracted from the MooTools core code. This page has not been written by an official MooTools developer and is solely intended to provide a basis for plugin developers to assimilate their coding style to the framework’s.
MooTools uses tabs for indentation. Trailing whitespace is discouraged as well as indentation for empty lines.
The commenting style of the framework preserves the Natural Docs syntax. Since Natural Docs is no longer being used by the MooTools project, the commenting style is up to the plugin developer.
function $A(iterable){
...
}
if (typeof a1 == 'string') return add(this, a1, a2, a3);
case 1: return 'element';
} else {
return ctx.getElementsByTagName(tag);
}
It’s always included.
It’s not included after the closing bracket, with the exception of the global object literal definition.
var MooTools = {
'version': '1.2.0',
'build': ''
};
Function Expressions
It’s always included after the closing bracket.
var foo = function(){
...
};
Function Declarations
It’s never included after the closing bracket.
this.headers.extend({'Accept': 'application/json', 'X-Request': 'JSON'});
object.implement = function(a1, a2, a3){
if (typeof a1 == 'string') return add(this, a1, a2, a3);
for (var p in a1) add(this, p, a1[p], a2);
return this;
};
Request.JSON = new Class({
Extends: Request,
...
success: function(text){ }
});
A single tab is used to indent code within a bracketed compound statement, unless it has been shortened. This also applies to subsequent, inner statements.
The use of the single quotation mark is preferred.
In Object literal expressions, quotation is generally omitted for the key part.
sender.send({data: this, url: url || sender.options.url});
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4