ShareThis Forums » Publishers

How to escape single quotes

(3 posts)
  • Started 3 months ago by lrivers
  • Latest reply from davemackey

  1. lrivers
    Member

    OK, I was having a problem where I was passing an article title to the sharethis JavaScript and the presence of single quotes (for example) was breaking the widget.

    I discovered that if I added the following script before the sharethis JavaScript and then calling this variable instead of the raw title works.

    Now, the system I'm using has an escape function built in, but so does JavaScript, which you can use to escape the title string.

    Hope that helps someone.

    <script type="text/javascript">
    escaped_title="{{ entry.title | escape }}";
    </script>
    Posted 3 months ago #
  2. Very helpful. Thanks. ShareThis team - any intent to fix this on your end?
    David.

    Posted 3 months ago #
  3. I'll add to this that if you are using smarty you can do something like this:
    summary:'{/literal}{$story_content|escape}{literal}'
    David.

    Posted 3 months ago #

RSS feed for this topic

Reply

You must log in to post.