How to escape quotes inside a literal string

I have something like this in my shortcode
{{ ‘<?= ($option==1?"class='no-sub'":"")?>’ | safeHTML }}

how do you escape the quotes inside the literal string?
I tried using backslashes but it didn’t work.

Try this:
{{ '<?= ($option==1?\"class=\'no-sub\'\":\"\")?>' | safeHTML }}

Didn’t have a chance to test. Hope this helps.

I already tried that but to be sure I tried it again. It didn’t work

You can use backquotes (`) and use anything inside that except backquotes without escaping.

Though, there seems to be some typo in that snippet… the number of opening/closing quotes don’t seem to match. Also I’m not familiar with that HTML syntax. Can you paste here what exactly you need to see in the final HTML?

Also, put your code in code blocks like this:

your code
1 Like

@ kaushalmodi

thanks. the backtick worked