rlei-odes opened a new pull request, #44020: URL: https://github.com/apache/superset/pull/44020
### SUMMARY The helper reference on the Handlebars Chart docs page lists nine helpers that are not registered. Calling any of them raises `Missing helper: "..."`, which renders the chart blank — so the page's own examples break the chart they are teaching you to build. The Math and String tables appear to have been written against [`handlebars-helpers`](https://github.com/helpers/handlebars-helpers), a different library. Superset registers [`just-handlebars-helpers`](https://github.com/leapfrogtechnology/just-handlebars-helpers), which spells them differently: | Documented | Actually registered | | --- | --- | | `add` | `sum` | | `subtract` | `difference` | | `multiply` | `multiplication` | | `divide` | `division` | | `round` | *no equivalent* — use `sprintf "%.0f"` | | `capitalize` | `capitalizeFirst` / `capitalizeEach` | | `truncate` | `excerpt` | | `contains` | *no equivalent* — see below | | `groupBy` | `group`, and the key is a `by=` hash argument | `contains` has no drop-in replacement. `includes` is array membership and returns `false` for a string, so it cannot check for a substring — documenting it as a `contains` equivalent would just move the bug. It is listed under a new **Arrays** heading with its actual contract. The change also: - fixes the `groupBy` example, which used both the wrong helper name and positional-argument syntax instead of `by="..."`; - adds a note explaining that the names differ from other Handlebars helper libraries, since that is the likely source of the original error; - documents helpers that are registered and useful but were missing — `sprintf`, `formatCurrency`, `concat`, `join`, `first`/`last`, `newLineToBr`, `abs`, `remainder`, `neqw`, `empty`, `count`; - notes that `sum` is binary and does not total an array, which is a common surprise when building totals in a template. The Comparison and Logical tables were already correct and are unchanged apart from the added `neqw` row. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF Not applicable — documentation only. ### TESTING INSTRUCTIONS Every helper name and inline example on the page was checked against the actual registry rather than read off. To reproduce: ```bash cd superset-frontend/plugins/plugin-chart-handlebars node -e " const hb = require('handlebars'); require('just-handlebars-helpers').registerHelpers(hb); require('handlebars-group-by').register(hb); for (const n of ['add','subtract','multiply','divide','round','capitalize','truncate','contains','groupBy']) { console.log((n in hb.helpers ? 'YES ' : 'NO ') + n); } " ``` All nine print `NO` before this change. Rendering any of them throws `Missing helper`, which blanks the chart. To check the corrected names the same way, substitute `sum`, `difference`, `multiplication`, `division`, `capitalizeFirst`, `capitalizeEach`, `excerpt`, `includes` and `group` — all print `YES`, and every example in the updated tables compiles and renders. In the UI: create a Handlebars chart on any dataset and paste `{{add 1 2}}` — the chart goes blank with `Missing helper: "add"` in the console. `{{sum 1 2}}` renders `3`. ### ADDITIONAL INFORMATION - [ ] Has associated issue: - [ ] Required feature flags: - [ ] Changes UI - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351)) - [ ] Migration is atomic, supports rollback & is backwards-compatible - [ ] Confirm DB migration upgrade and downgrade tested - [ ] Runtime estimates and downtime expectations provided - [ ] Introduces new feature or API - [ ] Removes existing feature or API -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
