Closed bpollack closed 1 year ago
What is the version you're using? I just tested it and it works fine:
const data = { arr: ["foo", "bar", "baz"] };
const filt = (arr) => arr.map((a) => a.toUpperCase()).join(" ")
{{ set foo = arr.filter(a => a !== 'bar') |> filt }}
{{ foo }}
It outputs FOO BAZ
0.5.0; I'll try 0.6.0 when I have a moment tonight
I can confirm this works correctly on v0.6.0, so I'll close. Thanks for preemptively fixing this before I had a chance to file the bug :)
While
{{ set }}
allows pipes on the righthand side, and it allows JavaScript on the righthand side, it can't handle JavaScript mixed with pipes. For example, assuming thatarr
is some form of array, andfilt
is some filter that expects an array, then this works:and this works
But this will fail with
> unexpected
:The fundamental issue is that
|>
is getting viewed as a JavaScript expression, not a pipe, and|>
is indeed not a valid JavaScript sigil. Gratuitous levels of parentheses that would make even the most grizzled Lisp user proud do not seem to be able to navigate around this.I honestly kind of get not being able to combine these, but it'd be nice either if the error message were more helpful, or if the documentation on this edge case were clearer