sadpandajoe commented on code in PR #43722:
URL: https://github.com/apache/superset/pull/43722#discussion_r3929632524


##########
superset-frontend/plugins/plugin-chart-handlebars/src/components/Handlebars/HandlebarsViewer.tsx:
##########
@@ -47,15 +53,18 @@ export const HandlebarsViewer = ({
 
   useMemo(() => {
     try {
-      const template = Handlebars.compile(templateSource);
-      const result = template(data);
-      setRenderedTemplate(result);
+      // The two sources are compiled separately so that Handlebars whitespace
+      // control (`~`) in one cannot strip text from the other, while
+      // expressions in the CSS field still expand.
+      const template = Handlebars.compile(templateSource)(data);
+      const style = styleSource ? Handlebars.compile(styleSource)(data) : '';

Review Comment:
   This refactor promises to preserve Handlebars expressions in the CSS field, 
but the new coverage only uses static CSS with an empty data set. Could we add 
a case such as `color: {{data.[0].color}}` and assert that the rendered style 
contains the expanded value, so a future context/compilation regression is 
caught?



-- 
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]

Reply via email to