You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/01/15 20:56:39 UTC

[GitHub] [superset] jdbranham commented on a change in pull request #17903: Feature: Adds plugin-chart-handlebars

jdbranham commented on a change in pull request #17903:
URL: https://github.com/apache/superset/pull/17903#discussion_r785351352



##########
File path: superset-frontend/plugins/plugin-chart-handlebars/src/components/Handlebars/HandlebarsViewer.tsx
##########
@@ -0,0 +1,33 @@
+import { SafeMarkdown } from '@superset-ui/core';
+import Handlebars from 'handlebars';
+import moment from 'moment';
+import React, { useMemo, useState } from 'react';
+
+export interface HandlebarsViewerProps {
+  templateSource: string;
+  data: any;
+}
+
+export const HandlebarsViewer = ({
+  templateSource,
+  data,
+}: HandlebarsViewerProps) => {
+  const [renderedTemplate, setRenderedTemplate] = useState('');
+
+  useMemo(() => {
+    const template = Handlebars.compile(templateSource);
+    const result = template(data);
+    setRenderedTemplate(result);
+  }, [templateSource, data]);

Review comment:
       Excellent suggestion!




-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org