How to format server side binding to have " character in string?

Hi all,

Trying to implement google's breadcrumb script combined with server side rendering and when I bind the value, all the " characters become " and google cannot read it.

<script type="application/ld+json">
   <%=_('breadcrumb',locals)%>
</script>

Result:

<script type="application/ld+json">
        {
      &#34;@context&#34;: &#34;https://schema.org&#34;,
      &#34;@type&#34;: &#34;BreadcrumbList&#34;,
      &#34;itemListElement&#34;: [{
        &#34;@type&#34;: &#34;ListItem&#34;,
        &#34;position&#34;: 1,
        &#34;name&#34;: &#34;Books&#34;,
        &#34;item&#34;: &#34;https://example.com/books&#34;
      },{
        &#34;@type&#34;: &#34;ListItem&#34;,
        &#34;position&#34;: 2,
        &#34;name&#34;: &#34;Science Fiction&#34;,
        &#34;item&#34;: &#34;https://example.com/books/sciencefiction&#34;
      }]
    }
    </script>

Also tried with inner text, the formatting was good but google didn't like it.

Any idea?
Gabor

Check this answer:

Seriously, I played with this for like an hour to get it work :smiley:
Thanks so much Apple!

I guess some years ago I ran into the same problem :slight_smile:

Nowadays I know this is called "escaping", and I know the template engine Wappler uses for NodeJS is called EJS, so I searched about EJS escaping

Happy to help!

1 Like