Skip to content

Commit

Permalink
API: extend class missing escape attribute used for elements FE (#2115)
Browse files Browse the repository at this point in the history
  • Loading branch information
maurofmferrao committed Sep 26, 2023
1 parent de55174 commit e74eff4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/Widget/Render/WidgetHtmlRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@ private function render(
'extends' => [
'override' => $moduleTemplate->extends?->override,
'with' => $moduleTemplate->extends?->with,
'escapeHtml' => $moduleTemplate->extends?->escapeHtml,
],
];
} else if ($extension !== null) {
Expand All @@ -654,6 +655,7 @@ private function render(
'extends' => [
'override' => $moduleTemplate->extends?->override,
'with' => $moduleTemplate->extends?->with,
'escapeHtml' => $moduleTemplate->extends?->escapeHtml,
],
];

Expand Down
3 changes: 3 additions & 0 deletions modules/src/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,13 +575,16 @@ $(function() {
elementCopy.hbs = null;
elementCopy.dataOverride = null;
elementCopy.dataOverrideWith = null;
elementCopy.escapeHtml = null;

// Compile the template if it exists
if ($template && $template.length > 0) {
elementCopy.dataOverride =
$template?.data('extends-override');
elementCopy.dataOverrideWith =
$template?.data('extends-with');
elementCopy.escapeHtml =
$template?.data('escape-html');

elementCopy.hbs = Handlebars.compile($template.html());
}
Expand Down
6 changes: 5 additions & 1 deletion modules/templates/global-elements.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,11 @@
{{#if textShadow}}text-shadow: {{shadowX}}px {{shadowY}}px {{shadowBlur}}px {{textShadowColor}};{{/if}}
width: 100%; height: 100%;"
>
<div>{{{text}}}</div>
{{#if escapeHtml}}
<div>{{text}}</div>
{{else}}
<div>{{{text}}}</div>
{{/if}}
</div>
]]></hbs>
</stencil>
Expand Down
1 change: 1 addition & 0 deletions modules/widget-html-render.twig
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
data-gap="{{ item.gapBetweenHbs }}"
data-extends-override="{{ item.extends.override }}"
data-extends-with="{{ item.extends.with }}"
data-escape-html="{{ item.extends.escapeHtml }}"
>{{ item.content|raw }}</script>
{% endfor %}
{% for widgetId, parser in onInitialize %}
Expand Down
3 changes: 3 additions & 0 deletions ui/src/layout-editor/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,9 @@ Viewer.prototype.renderElementContent = function(
}
}

// Escape HTML
convertedProperties.escapeHtml = template?.extends?.escapeHtml;

// Compile hbs template with data
let hbsHtml = hbsTemplate(convertedProperties);

Expand Down

0 comments on commit e74eff4

Please sign in to comment.