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


##########
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:
   Good call, the existing cases only ever exercised static CSS. Added a test 
in b6aa961 that renders `color: {{data.[0].color}}` in the CSS field against 
real data and asserts the style block contains the expanded value. The template 
in that case reads the same data, so it also pins down that both sources 
compile against the same context. Verified the test fails if the CSS is passed 
through uncompiled.
   
   ---
   🤖 _Drafted by Claude Code, co-signed by @sfirke._



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