hsx-jmacro 7.1.1 → 7.2.0
raw patch · 2 files changed
+9/−12 lines, 2 filesdep +wl-pprint-textdep −prettydep ~jmacro
Dependencies added: wl-pprint-text
Dependencies removed: pretty
Dependency ranges changed: jmacro
Files
- HSX/JMacro.hs +6/−9
- hsx-jmacro.cabal +3/−3
HSX/JMacro.hs view
@@ -75,12 +75,13 @@ import Control.Monad.Trans (lift) import Control.Monad.State (MonadState(get,put))+import Data.Text.Lazy (Text) import qualified Happstack.Server.HSP.HTML as HTML import Happstack.Server.HSP.HTML (XML(..), Attribute(..), AttrValue(..)) import HSX.XMLGenerator (XMLGenerator(..), XMLGen(..), EmbedAsChild(..), EmbedAsAttr(..), IsName(..), Attr(..), Name) import qualified HSP.Identity as HSP import Language.Javascript.JMacro (JStat(..), JExpr(..), JVal(..), Ident(..), ToJExpr(..), toStat, jmacroE, jLam, jVarTy, jsToDoc, jsSaturate, renderPrefixJs)-import Text.PrettyPrint.HughesPJ (Style(..), Mode(..), renderStyle, style)+import Text.PrettyPrint.Leijen.Text (Doc, displayT, renderOneLine) -- | This class provides a monotonically increasing supply of non-duplicate 'Integer' values class IntegerSupply m where@@ -99,21 +100,17 @@ put (succ i) return i -instance (XMLGenerator m, IntegerSupply m) => EmbedAsChild m JStat where+instance (XMLGenerator m, IntegerSupply m, EmbedAsChild m Text) => EmbedAsChild m JStat where asChild jstat = do i <- lift nextInteger asChild $ genElement (Nothing, "script") [asAttr ("type" := "text/javascript")]- [asChild (renderStyle lineStyle $ renderPrefixJs (show i) jstat)]- where- lineStyle = style { mode= OneLineMode }+ [asChild (displayT $ renderOneLine $ renderPrefixJs (show i) jstat)] -instance (IntegerSupply m, IsName n, EmbedAsAttr m (Attr Name String)) => EmbedAsAttr m (Attr n JStat) where+instance (IntegerSupply m, IsName n, EmbedAsAttr m (Attr Name Text)) => EmbedAsAttr m (Attr n JStat) where asAttr (n := jstat) = do i <- lift nextInteger- asAttr $ (toName n := (renderStyle lineStyle $ renderPrefixJs (show i) jstat))- where- lineStyle = style { mode= OneLineMode }+ asAttr $ (toName n := (displayT $ renderOneLine $ renderPrefixJs (show i) jstat)) -- | Provided for convenience since @Ident@ is exported by both -- @HSP.Identity@ and @JMacro@. Using this you can avoid the need for an
hsx-jmacro.cabal view
@@ -1,5 +1,5 @@ Name: hsx-jmacro-Version: 7.1.1+Version: 7.2.0 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/@@ -22,7 +22,7 @@ base > 4 && <5, happstack-hsp == 7.1.*, hsx >= 0.10.2 && <0.11,- jmacro >= 0.5 && < 0.6,+ jmacro >= 0.6 && < 0.7, mtl >= 2.0 && < 2.2,- pretty,+ wl-pprint-text == 1.1.*, text == 0.11.*