Search

I am trying to embed a jQury javascript in my template and it throws an error:

Line that causes problems is:

  var msie6 = $.browser == 'msie' && $.browser.version < 7;

Apparently it doesn't like "&& ". Any ideas how to solve this namespace problem?

I am reluctant to put it in a separate .js file since this code is used only on one page.

It's not exactly a namespacing-problem but ampersands are used to delimit entities. You need to replace them by &#38; or put it in a CDATA block.

doh! why didn't I think of that... Thanks... Problem solved....

It seems that I was celebrating too early.

When I wrap everything in CDATA then the outcome is following:

var msie6 = $.browser == 'msie' &amp;&amp; $.browser.version &lt; 7;

When I write:

var msie6 = $.browser == 'msie' &#38;&#38; $.browser.version &#60; 7;

I get the exactly same result

I did some googling and it seems to be a common problem... One way to solve it would be to use xsl:text disable-output-escaping? This is a bit annoying since every time I need to use '&' or '<', I have to declare it... Has anybody got more elegant solution to this?

The best solution is: Don't embed the script code in your template, but use external JavaScript files.

:-)

you can try to use xsl:comment inside your script block and then do &amp; for each ampersand.

If someone have the same issue in the future, i managed to get the && with :

<xsl:text disable-output-escaping = "yes"><![CDATA[&&]]></xsl:text>

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details