Make Liquidjs RenderOptions available #24871
Replies: 5 comments
|
What kind of render options are you looking to override? |
|
In our specific case we want to make the template rendering fail if the a value is not set int the scope. see https://github.com/harttle/liquidjs/blob/542a75fd44eecdeac8e5ff9ab19ed334c194d86c/src/liquid-options.ts#L88 and strictVariables |
|
@jod3 That the only one? Seeing that the liquid options are pretty tied to server integration and performance1, I'm wondering if it makes more sense to just set that particular option globally across the board. Feels like a safe one to have regardless! Footnotes
|
Why do you think so? This whole issue is pretty much developer focused, so for sb. who wants to leave the basics and develop extensions living in directus. If it makes sense for a specific extension to render the template async it should not affect directus basic or impact the server (more than sync could do)? Or am I missing sth.
There might be good reasons to fallback to an empty string if a value is not set. Alternative is throwing an exceptions on missing values which might raise issues out there. |
Those extensions run within the context of the Directus server itself, so if you execute a long running sync function you will indeed affect the Directus api as a whole. Generally speaking exposing all options from a third party library like this means that we're tying ourselves to this library. We've shot ourselves in the foot with this in the past with things like keyv vs redis, where switching the underlying logic executing the behavior needs to be changed or swapped out, but because we supported the full public API of the internal APIs used we now either have to ship a big breaking change, or reimplement support for the previous library's options in the new one. I don't think liquidjs will go anywhere anytime soon, but at the same time I have to plan for long term stable use and options, which means I have to pay attention to what we have to / want to support rather than blanketly opening up everything and potentially cause issues later 🙂 |
Uh oh!
There was an error while loading. Please reload this page.
Describe the Improvement
We currently have a case where we want to render a liquid template with other RenderOptions than the defaults.
Proposal: Forward access to the RenderOptions in MailService.renderTemplate() and MailService.send()
https://github.com/directus/directus/blob/main/api/src/services/mail/index.ts#L27
https://github.com/directus/directus/blob/main/api/src/services/mail/index.ts#L81
https://github.com/directus/directus/blob/main/api/src/services/mail/index.ts#L96
All reactions