user257543
user257543

Reputation: 891

genshi and javascript ampersand?

I have the following javascript in my genshi template and I'm unsure how to get it to parse without errors:

floor = (!floor && floor !== 0)? 20 : floor;

I tried this:

floor = (!floor &amp&amp floor !== 0)? 20 : floor;

but it always produces this error:

'genshi.template.base.TemplateSyntaxError'> at not well-formed (invalid token)

any thoughts?

Upvotes: 1

Views: 1186

Answers (2)

user257543
user257543

Reputation: 891

The trick was to wrap the JS code in CDATA tags to hide the js from genshi but ALSO comment the cdata tags out for javascript

<script type="text/javascript">
    //<![CDATA[
    floor = (!floor && floor !== 0)? 20 : floor;
    // ]]>
</script>

Upvotes: 10

Dagg Nabbit
Dagg Nabbit

Reputation: 76736

You forgot the semicolons.

Does this work?

&amp;&amp;

If not, you could just cheat and rewrite it to not use ampersands.

floor = floor === 0 ? 0 : floor || 20;

Upvotes: 1

Related Questions