myVar = 'Hello';
result = myVar + (nexl.args.myExternalArg || '');
myVar variable is concatenated with nexl.args.myExternalArg. If myExternalArg
not provided
as argument it will be replaced with empty string.
nexl.print('Person name is ' + person.name);It will print a person.name value to the log.
// ... nexl.defaultExpression = '${arr1|arr2|concat()}'; // joining two arrays //...After that you don't need to provide the expression in HTTP request URL as expression=${arr1|arr2|concat()}.
function makeComplexCalculations() { // resolving arr1, eliminating duplicate values, sorting var x = nexl.nexlize('${arr1#U#S}'); // performing additional array aggregation... // ... return result; }The makeComplexCalculations() uses nexl API to evaluate the ${arr1#U#S} expression.
str1 = 'New'; str2 = 'York'; function demo() { return str1 + nexl.get('str2') + nexl.get('str3AsArg'); }This function should be used when you don't know weather a variable provided as argument or it just a variable declared in your JavaScript file.
// ... function produceNewVar() { nexl.set('weight', 68); }This will produce ( or override ) a weight = 68 JavaScript variable when you call a produceNewVar() function.
nexl.init = function() { // resolving an argument fullName = nexl.args.fullName; // extracting firstName and lastName with regex firstName = fullName.replace(/ .*/g, ''); lastName = fullName.replace(/^[^ ]* /g, ''); // producing firstName and lastName variables // JavaScript file remain unchanged, it valid only for current HTTP request nexl.set('firstName', firstName); nexl.set('lastName', lastName); // now you can reference firstName and lastName variables in nexl expression(s) };
nexl.addInitFunc(function(){...}, 50); nexl.addInitFunc(function(){...}, 10); nexl.addInitFunc(function(){...}, -3);