From 00a01936d4b7586dac324d119ee99105e4190ee2 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Sun, 26 Sep 2010 12:32:18 +0200 Subject: [PATCH] hamlet 0.5.1 --- Yesod/Widget.hs | 14 ++++++++++++++ yesod.cabal | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Yesod/Widget.hs b/Yesod/Widget.hs index 13101494..efbeacfa 100644 --- a/Yesod/Widget.hs +++ b/Yesod/Widget.hs @@ -2,6 +2,7 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE PackageImports #-} {-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE TypeFamilies #-} -- | Widgets combine HTML with JS and CSS dependencies with a unique identifier -- generator, allowing you to create truly modular HTML components. module Yesod.Widget @@ -61,6 +62,19 @@ instance Monoid (GWidget sub master ()) where -- | A 'GWidget' specialized to when the subsite and master site are the same. type Widget y = GWidget y y +instance HamletValue (GWidget s m ()) where + newtype HamletMonad (GWidget s m ()) a = + GWidget' { runGWidget' :: GWidget s m a } + type HamletUrl (GWidget s m ()) = Route m + toHamletValue = runGWidget' + htmlToHamletMonad = GWidget' . addBody . const + urlToHamletMonad url params = GWidget' $ + addBody $ \r -> preEscapedString (r url params) + fromHamletValue = GWidget' +instance Monad (HamletMonad (GWidget s m ())) where + return = GWidget' . return + x >>= y = GWidget' $ runGWidget' x >>= runGWidget' . y + -- | Lift an action in the 'GHandler' monad into an action in the 'GWidget' -- monad. liftHandler :: GHandler sub master a -> GWidget sub master a diff --git a/yesod.cabal b/yesod.cabal index 6c90ffc7..21f38577 100644 --- a/yesod.cabal +++ b/yesod.cabal @@ -32,7 +32,7 @@ library utf8-string >= 0.3.4 && < 0.4, template-haskell >= 2.4 && < 2.5, web-routes-quasi >= 0.6 && < 0.7, - hamlet >= 0.5.0 && < 0.6, + hamlet >= 0.5.1 && < 0.6, blaze-builder >= 0.1 && < 0.2, transformers >= 0.2 && < 0.3, clientsession >= 0.4.0 && < 0.5,