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 && floor !== 0)? 20 : floor;
but it always produces this error:
'genshi.template.base.TemplateSyntaxError'> at not well-formed (invalid token)
any thoughts?
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 && floor !== 0)? 20 : floor;
but it always produces this error:
'genshi.template.base.TemplateSyntaxError'> at not well-formed (invalid token)
any thoughts?
Share Improve this question edited Nov 6, 2018 at 1:19 lucascaro 19.6k4 gold badges42 silver badges48 bronze badges asked Mar 1, 2012 at 22:41 user257543user257543 8912 gold badges14 silver badges35 bronze badges2 Answers
Reset to default 10The trick was to wrap the JS code in CDATA tags to hide the js from genshi but ALSO ment the cdata tags out for javascript
<script type="text/javascript">
//<![CDATA[
floor = (!floor && floor !== 0)? 20 : floor;
// ]]>
</script>
You forgot the semicolons.
Does this work?
&&
If not, you could just cheat and rewrite it to not use ampersands.
floor = floor === 0 ? 0 : floor || 20;