'How to fix String including double quotation is breaking html markup in Smarty?

Please consider the following code:

{assign var="test_var" value="\"Think win-win.\" - A quote by whom? » MCQ Academy"}

<div class="story-data" data-title="{$test_var}"></div>

Result the broken html markup. please consider the screenshot: enter image description here

How to fix it?



Solution 1:[1]

Guess, I got the solution. I need to use php htmlentities() function.

Example: <div class="story-data" data-title="{$test_var|htmlentities}"></div>.

More detail at: https://www.php.net/manual/en/function.htmlentities.php

Feel free to write a batter solution if you have.

Thank you Guys.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Shah Alom