Skip to content

Commit

Permalink
feat(handlebars plugin): adding handlebars helpers for common math op…
Browse files Browse the repository at this point in the history
…erations (#20648)

* feat(plugin-chart-handlebars): add common helpers

* add import

* add declare module

Co-authored-by: Ville Brofeldt <ville.v.brofeldt@gmail.com>
  • Loading branch information
rusackas and villebro committed Jul 8, 2022
1 parent 4e6e87f commit 9856d88
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 4 deletions.
49 changes: 47 additions & 2 deletions superset-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"access": "public"
},
"dependencies": {
"handlebars": "^4.7.7"
"handlebars": "^4.7.7",
"just-handlebars-helpers": "^1.0.19"
},
"peerDependencies": {
"@superset-ui/chart-controls": "*",
Expand All @@ -39,8 +40,8 @@
"react-dom": "^16.13.1"
},
"devDependencies": {
"@types/lodash": "^4.14.149",
"@types/jest": "^26.0.0",
"@types/lodash": "^4.14.149",
"jest": "^26.0.1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import Handlebars from 'handlebars';
import moment from 'moment';
import React, { useMemo, useState } from 'react';
import { isPlainObject } from 'lodash';
import Helpers from 'just-handlebars-helpers';

export interface HandlebarsViewerProps {
templateSource: string;
Expand Down Expand Up @@ -73,3 +74,5 @@ Handlebars.registerHelper('stringify', (obj: any, obj2: any) => {
throw Error('Please call with an object. Example: `stringify myObj`');
return isPlainObject(obj) ? JSON.stringify(obj) : String(obj);
});

Helpers.registerHelpers(Handlebars);
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ declare module '*.png' {
const value: any;
export default value;
}

declare module 'just-handlebars-helpers';

0 comments on commit 9856d88

Please sign in to comment.