mirror of
https://github.com/byteverse/colonnade.git
synced 2024-09-11 06:45:41 +03:00
Merge pull request #15 from snoyberg/master
Compatibility with yesod-core 1.6
This commit is contained in:
commit
d2604f80cb
@ -4,7 +4,7 @@ packages:
|
||||
- 'blaze-colonnade'
|
||||
- 'lucid-colonnade'
|
||||
- 'siphon'
|
||||
# - 'yesod-colonnade'
|
||||
- 'yesod-colonnade'
|
||||
# - 'geolite-csv'
|
||||
# Dependency packages to be pulled from upstream that are not in the resolver
|
||||
# (e.g., acme-missiles-0.3)
|
||||
|
@ -22,10 +22,11 @@ module Yesod.Colonnade
|
||||
) where
|
||||
|
||||
import Yesod.Core
|
||||
import Yesod.Core.Types (Body(..),GWData(..),WidgetT(..))
|
||||
import Yesod.Core.Types (Body(..),GWData(..),WidgetFor(..),wdRef)
|
||||
import Colonnade (Colonnade,Headed,Headless)
|
||||
import Data.Text (Text)
|
||||
import Control.Monad
|
||||
import Data.IORef (modifyIORef')
|
||||
import Data.Monoid
|
||||
import Data.String (IsString(..))
|
||||
import Text.Blaze (Attribute,toValue)
|
||||
@ -47,9 +48,11 @@ data Cell site = Cell
|
||||
instance IsString (Cell site) where
|
||||
fromString = stringCell
|
||||
|
||||
instance Semigroup (Cell site) where
|
||||
Cell a1 c1 <> Cell a2 c2 = Cell (mappend a1 a2) (mappend c1 c2)
|
||||
instance Monoid (Cell site) where
|
||||
mempty = Cell mempty mempty
|
||||
mappend (Cell a1 c1) (Cell a2 c2) = Cell (mappend a1 a2) (mappend c1 c2)
|
||||
mappend = (<>)
|
||||
|
||||
-- | Create a 'Cell' from a 'Widget'
|
||||
cell :: WidgetT site IO () -> Cell site
|
||||
@ -189,12 +192,14 @@ li_ = liftParent H.li
|
||||
a_ = liftParent H.a
|
||||
|
||||
liftParent :: (Html -> Html) -> Attribute -> WidgetT site IO a -> WidgetT site IO a
|
||||
liftParent el attrs (WidgetT f) = WidgetT $ \hdata -> do
|
||||
(a,gwd) <- f hdata
|
||||
liftParent el attrs (WidgetFor f) = WidgetFor $ \hdata -> do
|
||||
a <- f hdata
|
||||
modifyIORef' (wdRef hdata) $ \gwd ->
|
||||
let Body bodyFunc = gwdBody gwd
|
||||
newBodyFunc render =
|
||||
el H.! attrs $ (bodyFunc render)
|
||||
return (a,gwd { gwdBody = Body newBodyFunc })
|
||||
in gwd { gwdBody = Body newBodyFunc }
|
||||
return a
|
||||
|
||||
|
||||
|
||||
|
@ -17,11 +17,11 @@ library
|
||||
exposed-modules:
|
||||
Yesod.Colonnade
|
||||
build-depends:
|
||||
base >= 4.9 && < 4.11
|
||||
base >= 4.9 && < 4.12
|
||||
, colonnade >= 1.2 && < 1.3
|
||||
, yesod-core >= 1.4 && < 1.5
|
||||
, conduit >= 1.2 && < 1.3
|
||||
, conduit-extra >= 1.2 && < 1.3
|
||||
, yesod-core >= 1.6 && < 1.7
|
||||
, conduit >= 1.3 && < 1.4
|
||||
, conduit-extra >= 1.3 && < 1.4
|
||||
, text >= 1.0 && < 1.3
|
||||
, blaze-markup >= 0.7 && < 0.9
|
||||
, blaze-html >= 0.8 && < 0.10
|
||||
|
Loading…
Reference in New Issue
Block a user