diff --git a/HSX/JMacro.hs b/HSX/JMacro.hs
--- a/HSX/JMacro.hs
+++ b/HSX/JMacro.hs
@@ -27,7 +27,7 @@
 import Control.Monad.Trans             (lift)
 import Control.Monad.State             (MonadState(get,put))
 import HSX.XMLGenerator                (XMLGenerator(..), XMLGen(..), EmbedAsChild(..), EmbedAsAttr(..), IsName(..), Attr(..), Name)
-import Language.Javascript.JMacro      (JStat(..), jsToDoc, jsSaturate, renderJs)
+import Language.Javascript.JMacro      (JStat(..), jsToDoc, jsSaturate, renderPrefixJs)
 import Text.PrettyPrint.HughesPJ       (Style(..), Mode(..), render, renderStyle, style)
 
 class IntegerSupply m where 
@@ -51,19 +51,11 @@
       do i <- lift nextInteger
          asChild $ genElement (Nothing, "script")
                     [asAttr ("type" := "text/javascript")]
-                    [asChild (escapeForHtml $ render $ jsToDoc $ jsSaturate (Just ('i' : show i)) jstat)]
-      where
-        escapeForHtml :: String -> String
-        escapeForHtml [] = []
-        escapeForHtml [c] = [c]
-        escapeForHtml (b:c:cs)
-            | b == '<' && c == '/' 
-                        = b : '\\' : c : (escapeForHtml cs)
-            | otherwise = b : escapeForHtml (c : cs)
+                    [asChild (render $ renderPrefixJs (show i) jstat)]
 
 instance (IntegerSupply m, IsName n, EmbedAsAttr m (Attr Name String)) => EmbedAsAttr m (Attr n JStat) where
   asAttr (n := jstat) = 
       do i <- lift nextInteger
-         asAttr $ (toName n := (renderStyle lineStyle $ jsToDoc $ jsSaturate (Just ('i' : show i)) jstat))
+         asAttr $ (toName n := (renderStyle lineStyle $ renderPrefixJs (show i) jstat))
       where
         lineStyle = style { mode= OneLineMode }
diff --git a/hsx-jmacro.cabal b/hsx-jmacro.cabal
--- a/hsx-jmacro.cabal
+++ b/hsx-jmacro.cabal
@@ -1,5 +1,5 @@
 Name:                hsx-jmacro
-Version:             6.0.1
+Version:             6.0.2
 Synopsis:            hsx+jmacro support
 Description:         HSX allows for the use of literal XML in Haskell program text. JMacro allows for the use of javascript-syntax for generating javascript in Haskell. This library makes it easy to embed JMacro generated javascript in HSX templates.
 Homepage:            http://www.happstack.com/
@@ -18,6 +18,6 @@
   Build-depends:       
                      base >4 && <5,
                      hsx,
-                     jmacro,
+                     jmacro >= 0.5 && < 0.6,
                      mtl,
                      pretty
