Thanks for the quick reply on the other question! Which actually made me discover a bug (I think).
When using for-each-document-item, it seems user-defined functions can't be used, as they are completely ignored. In the example below, the user-defined "trim" is ignored and the default "trim" is used and the user-defined "upper" is not found in the defaults, thus an error is returned:
const tots = require('json-tots')
const trim = str => str.trim()
const upper = str => str.toUpperCase()
const document = {this: [' one ', 'two ']}
const template = {that : ['{%%{this}}', '{{$} | trim | upper}']}
const result = tots.transform(template, {functions: {trim, upper}})(document)
console.log(result)
// expected: result = {that: ['ONE', 'TWO']}
Thanks for the quick reply on the other question! Which actually made me discover a bug (I think).
When using for-each-document-item, it seems user-defined functions can't be used, as they are completely ignored. In the example below, the user-defined "trim" is ignored and the default "trim" is used and the user-defined "upper" is not found in the defaults, thus an error is returned:
const tots = require('json-tots') const trim = str => str.trim() const upper = str => str.toUpperCase() const document = {this: [' one ', 'two ']} const template = {that : ['{%%{this}}', '{{$} | trim | upper}']} const result = tots.transform(template, {functions: {trim, upper}})(document) console.log(result) // expected: result = {that: ['ONE', 'TWO']}