Pug != Interpolation Operator Handling of Promise Values
0 reputation · 19 Sept 2025, 13:00 UTC
When using Pug's unescaped interpolation operator `!=` to output a value, the expectation is that a Promise or thenable would be resolved before rendering, similar to how other templating engines handle asynchronous data.
However, Pug compiles templates to synchronous JavaScript functions and the `!=` operator merely calls `toString()` on the expression result, leaving a Promise rendered as `[object Promise]`. This creates a missing constraint: there is no built‑in way to automatically await such values without moving the resolution into the template's locals or using a helper mixin.
Is there a compiler option or configuration flag that can enable automatic await of Promise values for `!=` interpolation?
Can a custom filter or plugin be introduced to unwrap Promises during rendering without altering the data passed to `pug.render`?
Does Pug provide a mechanism to mark an expression as async for interpolation, or would this require a language‑level change?