keithamus/R.js — pull request #3 by ischenkodv (2014-06-13 21:26:15+00:00)
Title: Prevent parsing strings that do not contains placeholders.

Function call R('mystring') calls parseVariables function even if we didn't pass any parameters to it.
If you pass at least two parameters to R() then "if" expression will be called. Hence calling R() with just translation label will execute "else" block and [variables] will always be equal to [undefined] thus triggering label parsing.

eR = function (id, variables) {
// If we haven't initialised our variables etc, then do so.
if (!inited) R.init();

if (arguments.length > 1) {

// In the case we've been given comma separated arguments, we should
// load them into an array and send them to render
var args = R.slice(arguments);
args.shift();

return R.render(id, args);

// Otherwise just send the `variables` var.
} else {
return R.render(id, [variables]);
}
};