title: Escape JS and PHP blocks for Smarty 2
body: <p>Later Edit: This issue has been fixed. It seems that the problem was with a misplaced hook.</p>
  
  <p>What is the right and best way to escape the JavaScript and PHP blocks in Smarty 2?</p>
  
  <p>I have tried to: </p>
  
  <ul>
  <li>change every JS {} with {ldelim} respectiely {rdelim};</li>
  <li>add {literal} before  and {/literal} after </li>
  <li>add {php}phpcodehere{/php}</li>
  </ul>
  
  <p>None of them seem to work.</p>
  
  <p>Here is my code that needs to be escaped:</p>
  
  <pre><code>&lt;script&gt;
      var _ra = _ra || {};
      _ra.sendProductInfo = {
          "id": "{$product.product_id}",
          "name": "{$product.product}",
          "url": "{$config.current_url|fn_url}",
          "img": "{$product.main_pair.detailed.image_path}",
          {if $ra_oldPrice == $product.price or not is_numeric($ra_oldPrice)}
          "price": "{if $product.list_price &gt; $product.price}{$product.list_price}{else}{$product.price}{/if}",
          "promo": "{if $product.list_price &gt; $product.price}{$product.price}{else}0{/if}",
          {else}
          "price": "{$ra_oldPrice}",
          "promo": "{$product.price}",
          {/if}
          "brand": false,
          "category": [{
              "id": "{$catid}",
              "name": "{$product.main_category|fn_get_category_name}",
              "parent": false,
              "breadcrumb": []
          }],
          "inventory": {
              "variations": false,
              "stock": "{$product_amount = $product.inventory_amount|default:$product.amount}{if ($product_amount &lt;= 0 || $product_amount &lt; $product.min_qty) &amp;&amp; $settings.General.inventory_tracking == "Y"}0{else}1{/if}"   
          }
      };
  &lt;/script&gt;
  </code></pre>