Langley
Langley

Reputation: 61

Problem embedding javascript for loops in liftweb static content

Here's what I tried... I put this in a file called <mySbtBasedProjdir>/src/main/webapp/static/simpleForLoop.html

<lift:surround with="default" at="content">

Why is this a problem in liftweb?

<script type="text/javascript">
  var i=0;
  for (i=0;i<=5;i++) {
    document.write("The number is " + i);
    document.write("<br />");
  }
</script>

</lift:surround>

The error I get starts with:

scala.xml.dtd.ValidationException: :5:14: name expectednet.liftweb.util.PCDataXmlParser.reportSyntaxError(PCDataMarkupParser.scala:174)

Upvotes: 1

Views: 313

Answers (1)

BGerrissen
BGerrissen

Reputation: 21680

You need to enclose it inside CDATA tags I think

<![CDATA[
<script etc ...
</script>
]]>

So the parser ignores it.

Upvotes: 2

Related Questions