packages feed

hsp 0.5.2 → 0.6.0

raw patch · 7 files changed

+27/−13 lines, 7 filesdep +text

Dependencies added: text

Files

hsp.cabal view
@@ -1,5 +1,5 @@ Name:                   hsp-Version:                0.5.2+Version:                0.6.0 License:                BSD3 License-File:           LICENSE Author:                 Niklas Broberg, Joel Bjornson@@ -21,12 +21,12 @@ Homepage:               http://code.google.com/p/hsp Build-Type:             Simple Cabal-Version:          >= 1.2.3-Tested-With:            GHC==6.8.3+Tested-With:            GHC==6.8.3, GHC==6.10, GHC==7.0.2  Flag base4  Library-  Build-Depends:        base >3 && < 5, mtl, harp, hsx>=0.7.0, HJScript>=0.5.0+  Build-Depends:        base >3 && < 5, mtl, harp, hsx>=0.7.0, HJScript>=0.5.0, text   if flag(base4)     Build-depends:      base >= 4 && < 5     cpp-options:        -DBASE4
src/HSP.hs view
@@ -21,8 +21,7 @@ 
     ) where
 
-import Prelude hiding (catch)
-
+import Prelude ()
 import HSP.Monad
 import HSP.Env hiding (mkSimpleEnv)
 import HSP.XML hiding (Name)
src/HSP/Exception.hs view
@@ -1,5 +1,4 @@-{-# LANGUAGE CPP #-}-{-# OPTIONS -fglasgow-exts #-}+{-# LANGUAGE CPP, DeriveDataTypeable #-} ----------------------------------------------------------------------------- -- | -- Module      :  HSP.Exception
src/HSP/HJScript.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE TypeSynonymInstances, FlexibleInstances, MultiParamTypeClasses, FlexibleContexts #-}
 {-# OPTIONS_GHC -F -pgmFtrhsx #-}
 module HSP.HJScript where
 
@@ -14,9 +15,6 @@       <% show b %>
     </script>
 
-instance Monad m => EmbedAsChild (HSPT' m) (HJScript ()) where
-  asChild script = asChild . snd $ evalHJScript script
-
 instance Monad m => IsAttrValue m (Block t) where
   toAttrValue block = return . attrVal $ "javascript:" ++ show block
 
@@ -25,6 +23,9 @@ 
 instance Monad m => IsAttrValue m (HJScript (Exp t)) where
   toAttrValue script = toAttrValue $ evaluateHJScript script
+
+scriptAsChild :: (EmbedAsChild m String) => HJScript () -> XMLGenT m [HSX.Child m]
+scriptAsChild script = asChild $ show $ snd $ evalHJScript script
 
 newGlobalVar :: HSP (Var t, Block ())
 newGlobalVar = do
src/HSP/HTML.hs view
@@ -108,6 +108,8 @@          in open . cs . close   where renderChildren :: Int -> Children -> ShowS         renderChildren n' cs = foldl (.) id $ map (renderAsHTML' (n'+2)) cs+renderElement _ _ = error "internal error: renderElement only suports the Element constructor."+  renderTag :: TagType -> Int -> Name -> Attributes -> ShowS  renderTag typ n name attrs = 
src/HSP/Monad.hs view
@@ -25,9 +25,8 @@  -- Monad imports -- import Control.Monad.Reader (ReaderT(..), ask, lift)-import Control.Monad.RWS (RWST(..), ask, lift, put)-import Control.Monad.State-import Control.Monad.Trans (MonadIO(..))+import Control.Monad.RWS (RWST(..), ask, put)+import Control.Monad.Trans (MonadIO(..), lift)  import Prelude hiding (catch) 
src/HSP/XMLGenerator.hs view
@@ -21,6 +21,8 @@ 
 --import Control.Monad (liftM)
 import Control.Monad.Trans (lift)
+import qualified Data.Text as T
+import qualified Data.Text.Lazy as TL
 
 --import Data.List (intersperse)
 
@@ -114,6 +116,12 @@ instance Monad m => EmbedAsChild (HSPT' m) Char where
  asChild = asChild . (:[])
 
+instance (Monad m, Functor m) => (EmbedAsChild (HSPT' m) TL.Text) where
+    asChild = asChild . TL.unpack
+
+instance (Monad m, Functor m) => (EmbedAsChild (HSPT' m) T.Text) where
+    asChild = asChild . T.unpack
+
 {-
 -- | If something can be represented as a list of XML, then a list of 
 -- that something can also be represented as a list of XML.
@@ -180,6 +188,12 @@ -- | Strings can be directly represented as values.
 instance Monad m => IsAttrValue m String where
  toAttrValue = return . pAttrVal
+
+instance (Monad m) => IsAttrValue m T.Text where
+    toAttrValue = toAttrValue . T.unpack
+
+instance (Monad m) => IsAttrValue m TL.Text where
+    toAttrValue = toAttrValue . TL.unpack
 
 instance Monad m => IsAttrValue m Int where
  toAttrValue = toAttrValue . show