Move away from RepHtml some more
This commit is contained in:
parent
44c5b03a6e
commit
743966898d
@ -83,11 +83,11 @@ class RenderRoute site => Yesod site where
|
||||
errorHandler = defaultErrorHandler
|
||||
|
||||
-- | Applies some form of layout to the contents of a page.
|
||||
defaultLayout :: WidgetT site IO () -> HandlerT site IO RepHtml
|
||||
defaultLayout :: WidgetT site IO () -> HandlerT site IO Html
|
||||
defaultLayout w = do
|
||||
p <- widgetToPageContent w
|
||||
mmsg <- getMessage
|
||||
hamletToRepHtml [hamlet|
|
||||
giveUrlRenderer [hamlet|
|
||||
$newline never
|
||||
$doctype 5
|
||||
<html>
|
||||
|
||||
@ -266,6 +266,7 @@ data Content = ContentBuilder !BBuilder.Builder !(Maybe Int) -- ^ The content an
|
||||
data TypedContent = TypedContent !ContentType !Content
|
||||
|
||||
type RepHtml = Html
|
||||
{-# DEPRECATED RepHtml "Please use Html instead" #-}
|
||||
newtype RepJson = RepJson Content
|
||||
newtype RepPlain = RepPlain Content
|
||||
newtype RepXml = RepXml Content
|
||||
|
||||
@ -19,6 +19,7 @@ module Yesod.Core.Widget
|
||||
, whamlet
|
||||
, whamletFile
|
||||
, ihamletToRepHtml
|
||||
, ihamletToHtml
|
||||
-- * Convert to Widget
|
||||
, ToWidget (..)
|
||||
, ToWidgetHead (..)
|
||||
@ -220,7 +221,16 @@ rules = do
|
||||
ihamletToRepHtml :: (MonadHandler m, RenderMessage (HandlerSite m) message)
|
||||
=> HtmlUrlI18n message (Route (HandlerSite m))
|
||||
-> m Html
|
||||
ihamletToRepHtml ih = do
|
||||
ihamletToRepHtml = ihamletToHtml
|
||||
{-# DEPRECATED ihamletToRepHtml "Please use ihamletToHtml instead" #-}
|
||||
|
||||
-- | Wraps the 'Content' generated by 'hamletToContent' in a 'RepHtml'.
|
||||
--
|
||||
-- Since 1.2.1
|
||||
ihamletToHtml :: (MonadHandler m, RenderMessage (HandlerSite m) message)
|
||||
=> HtmlUrlI18n message (Route (HandlerSite m))
|
||||
-> m Html
|
||||
ihamletToHtml ih = do
|
||||
urender <- getUrlRenderParams
|
||||
mrender <- getMessageRender
|
||||
return $ ih (toHtml . mrender) urender
|
||||
|
||||
@ -35,7 +35,7 @@ handleForbiddenR = return ()
|
||||
|
||||
handleNeedsLoginJsonR :: Handler RepJson
|
||||
handleNeedsLoginJsonR = return $ repJson $ object []
|
||||
handleNeedsLoginHtmlR :: Handler RepHtml
|
||||
handleNeedsLoginHtmlR :: Handler Html
|
||||
handleNeedsLoginHtmlR = return ""
|
||||
|
||||
test :: String -- ^ method
|
||||
|
||||
@ -26,7 +26,7 @@ mkYesod "App" [parseRoutes|
|
||||
|
||||
instance Yesod App
|
||||
|
||||
getHomeR :: Handler RepHtml
|
||||
getHomeR :: Handler Html
|
||||
getHomeR = do
|
||||
$logDebug "Testing logging"
|
||||
defaultLayout $ toWidget [hamlet|
|
||||
@ -42,7 +42,7 @@ $doctype 5
|
||||
<input type=submit value="BUGGY: Error thrown after runRequestBody">
|
||||
|]
|
||||
|
||||
postNotFoundR, postFirstThingR, postAfterRunRequestBodyR :: Handler RepHtml
|
||||
postNotFoundR, postFirstThingR, postAfterRunRequestBodyR :: Handler Html
|
||||
postNotFoundR = do
|
||||
(_, _files) <- runRequestBody
|
||||
_ <- notFound
|
||||
@ -57,12 +57,12 @@ postAfterRunRequestBodyR = do
|
||||
_ <- error $ show $ fst x
|
||||
getHomeR
|
||||
|
||||
getErrorInBodyR :: Handler RepHtml
|
||||
getErrorInBodyR :: Handler Html
|
||||
getErrorInBodyR = do
|
||||
let foo = error "error in body 19328" :: String
|
||||
defaultLayout [whamlet|#{foo}|]
|
||||
|
||||
getErrorInBodyNoEvalR :: Handler (DontFullyEvaluate RepHtml)
|
||||
getErrorInBodyNoEvalR :: Handler (DontFullyEvaluate Html)
|
||||
getErrorInBodyNoEvalR = fmap DontFullyEvaluate getErrorInBodyR
|
||||
|
||||
errorHandlingTest :: Spec
|
||||
|
||||
@ -17,7 +17,7 @@ mkYesod "H" [parseRoutes|
|
||||
instance Yesod H where
|
||||
jsLoader _ = BottomOfHeadBlocking
|
||||
|
||||
getHeadR :: Handler RepHtml
|
||||
getHeadR :: Handler Html
|
||||
getHeadR = defaultLayout $ addScriptRemote "load.js"
|
||||
|
||||
specs :: Spec
|
||||
|
||||
@ -12,6 +12,5 @@ mkYesod "B" [parseRoutes|
|
||||
instance Yesod B where
|
||||
jsLoader _ = BottomOfBody
|
||||
|
||||
getBottomR :: Handler RepHtml
|
||||
getBottomR :: Handler Html
|
||||
getBottomR = defaultLayout $ addScriptRemote "load.js"
|
||||
|
||||
|
||||
@ -36,13 +36,13 @@ instance PathPiece (Foo x y)
|
||||
|
||||
instance Yesod Y
|
||||
|
||||
getRootR :: Handler RepHtml
|
||||
getRootR :: Handler Html
|
||||
getRootR = defaultLayout $ toWidget [hamlet|<a href=@{RootR}>|]
|
||||
|
||||
getTextR :: Text -> Handler RepHtml
|
||||
getTextR :: Text -> Handler Html
|
||||
getTextR foo = defaultLayout $ toWidget [hamlet|%#{foo}%|]
|
||||
|
||||
getTextsR :: [Text] -> Handler RepHtml
|
||||
getTextsR :: [Text] -> Handler Html
|
||||
getTextsR foos = defaultLayout $ toWidget [hamlet|%#{show foos}%|]
|
||||
|
||||
getRT1 :: [Text] -> Handler ()
|
||||
|
||||
@ -23,13 +23,13 @@ instance Yesod Y where
|
||||
else "all.css"
|
||||
_ -> return Nothing
|
||||
|
||||
getRootR :: Handler RepHtml
|
||||
getRootR :: Handler Html
|
||||
getRootR = defaultLayout $ do
|
||||
toWidget [lucius|foo1{bar:baz}|]
|
||||
toWidgetMedia "screen" [lucius|foo2{bar:baz}|]
|
||||
toWidget [lucius|foo3{bar:baz}|]
|
||||
|
||||
getStaticR :: Handler RepHtml
|
||||
getStaticR :: Handler Html
|
||||
getStaticR = getRootR
|
||||
|
||||
runner :: Session () -> IO ()
|
||||
|
||||
@ -18,10 +18,10 @@ getSubsite _ = Subsite $(mkYesodSubDispatch resourcesSubsite)
|
||||
getBarR :: Monad m => m T.Text
|
||||
getBarR = return $ T.pack "BarR"
|
||||
|
||||
getBazR :: Yesod master => HandlerT Subsite (HandlerT master IO) RepHtml
|
||||
getBazR :: Yesod master => HandlerT Subsite (HandlerT master IO) Html
|
||||
getBazR = lift $ defaultLayout [whamlet|Used Default Layout|]
|
||||
|
||||
getBinR :: Yesod master => HandlerT Subsite (HandlerT master IO) RepHtml
|
||||
getBinR :: Yesod master => HandlerT Subsite (HandlerT master IO) Html
|
||||
getBinR = do
|
||||
widget <- widgetToParentWidget [whamlet|
|
||||
<p>Used defaultLayoutT
|
||||
|
||||
@ -31,7 +31,7 @@ mkYesod "Y" [parseRoutes|
|
||||
instance Yesod Y where
|
||||
approot = ApprootStatic "http://test"
|
||||
|
||||
getRootR :: Handler RepHtml
|
||||
getRootR :: Handler Html
|
||||
getRootR = defaultLayout $ toWidgetBody [julius|<not escaped>|]
|
||||
|
||||
getMultiR :: [String] -> Handler ()
|
||||
@ -46,7 +46,7 @@ instance RenderMessage Y Msg where
|
||||
renderMessage a (_:xs) y = renderMessage a xs y
|
||||
renderMessage a [] y = renderMessage a ["en"] y
|
||||
|
||||
getTowidgetR :: Handler RepHtml
|
||||
getTowidgetR :: Handler Html
|
||||
getTowidgetR = defaultLayout $ do
|
||||
toWidget [julius|foo|] :: Widget
|
||||
toWidgetHead [julius|foo|]
|
||||
@ -59,7 +59,7 @@ getTowidgetR = defaultLayout $ do
|
||||
toWidgetHead [hamlet|<foo>|]
|
||||
toWidgetBody [hamlet|<foo>|]
|
||||
|
||||
getWhamletR :: Handler RepHtml
|
||||
getWhamletR :: Handler Html
|
||||
getWhamletR = defaultLayout [whamlet|
|
||||
$newline never
|
||||
<h1>Test
|
||||
@ -74,7 +74,7 @@ getWhamletR = defaultLayout [whamlet|
|
||||
<h4>Embed
|
||||
|]
|
||||
|
||||
getAutoR :: Handler RepHtml
|
||||
getAutoR :: Handler Html
|
||||
getAutoR = defaultLayout [whamlet|
|
||||
$newline never
|
||||
^{someHtml}
|
||||
@ -82,7 +82,7 @@ $newline never
|
||||
where
|
||||
someHtml = [shamlet|somehtml|]
|
||||
|
||||
getJSHeadR :: Handler RepHtml
|
||||
getJSHeadR :: Handler Html
|
||||
getJSHeadR = defaultLayout $ toWidgetHead [julius|alert("hello");|]
|
||||
|
||||
widgetTest :: Spec
|
||||
|
||||
Loading…
Reference in New Issue
Block a user