mirror of
https://github.com/discourse/discourse.git
synced 2024-12-25 10:53:56 +08:00
bc9558550d
`registerUnbound` was present for legacy reasons when using helpers in raw-hbs and has been replaced by `registerRawHelper`. For new helpers used only in classic ember template, exporting a default function from `helpers/*.js` is recommended. This change also means that all existing helpers will be available to import in `gjs` files. Co-authored-by: David Taylor <david@taylorhq.com>
18 lines
386 B
JavaScript
18 lines
386 B
JavaScript
import { registerRawHelper } from "discourse-common/lib/helpers";
|
|
|
|
registerRawHelper("value-at-tl", valueAtTl);
|
|
|
|
export default function valueAtTl(data, params = {}) {
|
|
let tl = parseInt(params.level, 10);
|
|
if (data) {
|
|
let item = data.find(function (d) {
|
|
return parseInt(d.x, 10) === tl;
|
|
});
|
|
if (item) {
|
|
return item.y;
|
|
} else {
|
|
return 0;
|
|
}
|
|
}
|
|
}
|