mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
fix(plugin-chart-handlebars): fix overflow, debounce and control reset (#19879)
* fix(plugin-chart-handlebars): fix overflow * add debounce, fix reset controls * fix deps * remove redundant code * improve examples * add last missing resetOnHides * fix test * use isPlainObject
This commit is contained in:
@@ -20,6 +20,7 @@ import { SafeMarkdown, styled } from '@superset-ui/core';
|
||||
import Handlebars from 'handlebars';
|
||||
import moment from 'moment';
|
||||
import React, { useMemo, useState } from 'react';
|
||||
import { isPlainObject } from 'lodash';
|
||||
|
||||
export interface HandlebarsViewerProps {
|
||||
templateSource: string;
|
||||
@@ -64,3 +65,11 @@ Handlebars.registerHelper('dateFormat', function (context, block) {
|
||||
const f = block.hash.format || 'YYYY-MM-DD';
|
||||
return moment(context).format(f);
|
||||
});
|
||||
|
||||
// usage: {{ }}
|
||||
Handlebars.registerHelper('stringify', (obj: any, obj2: any) => {
|
||||
// calling without an argument
|
||||
if (obj2 === undefined)
|
||||
throw Error('Please call with an object. Example: `stringify myObj`');
|
||||
return isPlainObject(obj) ? JSON.stringify(obj) : String(obj);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user