Closed iamfaizanrashid closed 3 months ago
@iamfaizanrashid {{json @root}}
is a Handelbars template. It's not supported in the JavaScript.
If you are using the latest version of the Dynamic Text Panel, you can access your data using context.data
. Please take a look at the latest blog for details: https://volkovlabs.io/blog/dynamictext-panel-4.3.0-20240108/
in content box ===> working
<div class="custom-pre""> {{{json @root}}}
in css box =====> working
.custom-pre { color: rgb(218, 143, 45); background-color: rgb(46, 50, 51); padding: 10px; overflow: auto; white-space: pre-wrap; }
in javascript box =====> not working
const jsonData = JSON.parse('{{json @root}}'); const filteredData = Object.entries(jsonData) .filter(([key, value]) => value > 0) .map(([key, value]) =>
"${key}": ${value},
) .join('\n');// Display filtered data in a separate element (optional) const filteredElement = document.createElement('div'); filteredElement.classList.add('custom-pre'); filteredElement.textContent = filteredData.slice(0, -1); // Remove the trailing comma document.body.appendChild(filteredElement);
when we add java script it don't work in dynamic text panel