sdawood / json-tots

JSON Template of Templates
MIT License
9 stars 4 forks source link

Issue: user-defined functions are ignored when using for-each-document-item #4

Closed infinioo closed 5 years ago

infinioo commented 5 years ago

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']}

sdawood commented 5 years ago

Investigating, thanks