Closed pmeinhardt closed 4 years ago
Plus, I agree this could use some more help on the preferences page. Even though the error feedback is already an awesome step in the right direction. Do you want to do it in this PR or tackle it as a separate one?
Maybe we can think about what the help should look like here first. At the moment, the options page lists only the helper names. This was sufficient before, when helpers did not take any arguments.
Now, we probably need at least a hint for what arguments a helper accepts. E.g. I could imagine the following for our new helpers:
substring(start-index[, end-index])
truncate(max-length)
We could achieve this by assigning an optional description
property to the helpers and rendering that on the options page if defined. E.g.
export const substring = (...args) => (s) => s.substring(...args);
substring.description = 'substring(start-index[, end-index])';
Sorry it took me so long to get back to this @pmeinhardt 🙈 (blog business...)
I think the format you suggested here fits perfect and I would suggest to go that route:
substring(start-index[, end-index])
truncate(max-length)
Should we have this as a separate PR and just merge this as it is?
I've quickly added it here @klappradla (see the last commit). Looks like this
I was intrigued @bitboxer and had a moment this morning to throw something together.
It allows for (optionally) parameterized filters in templates, e.g.:
I've also changed how we handle errors in template expressions, hoping to make it easier to figure out what's going wrong in case of typos and erroneous templates. For instance:
Title is "!!(no helper named "truncate")"
if atruncate
helper doesn't exist…{value | truncate(crash)}
it will return…!!(invalid parameters provided to "truncate": crash)
From what I can see, there's at least two more to-dos:
{value | }
Please take it for a spin when you have time.
Happy about feedback. 🙂
Closes #233.