Major renaming of widget functions
This commit is contained in:
parent
b5622c4a71
commit
17cb10c312
@ -44,7 +44,6 @@ module Yesod.Form.Fields
|
|||||||
|
|
||||||
import Yesod.Form.Core
|
import Yesod.Form.Core
|
||||||
import Yesod.Form.Profiles
|
import Yesod.Form.Profiles
|
||||||
import Yesod.Widget
|
|
||||||
import Data.Time (Day, TimeOfDay)
|
import Data.Time (Day, TimeOfDay)
|
||||||
import Text.Hamlet
|
import Text.Hamlet
|
||||||
import Data.Monoid
|
import Data.Monoid
|
||||||
@ -121,7 +120,7 @@ boolField ffs orig = toForm $ do
|
|||||||
{ fiLabel = string label
|
{ fiLabel = string label
|
||||||
, fiTooltip = tooltip
|
, fiTooltip = tooltip
|
||||||
, fiIdent = theId
|
, fiIdent = theId
|
||||||
, fiInput = addBody [$hamlet|
|
, fiInput = [$hamlet|
|
||||||
%input#$theId$!type=checkbox!name=$name$!:val:checked
|
%input#$theId$!type=checkbox!name=$name$!:val:checked
|
||||||
|]
|
|]
|
||||||
, fiErrors = case res of
|
, fiErrors = case res of
|
||||||
@ -175,7 +174,7 @@ selectField pairs ffs initial = toForm $ do
|
|||||||
{ fiLabel = string label
|
{ fiLabel = string label
|
||||||
, fiTooltip = tooltip
|
, fiTooltip = tooltip
|
||||||
, fiIdent = theId
|
, fiIdent = theId
|
||||||
, fiInput = addBody input
|
, fiInput = input
|
||||||
, fiErrors = case res of
|
, fiErrors = case res of
|
||||||
FormFailure [x] -> Just $ string x
|
FormFailure [x] -> Just $ string x
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
@ -220,7 +219,7 @@ maybeSelectField pairs ffs initial' = toForm $ do
|
|||||||
{ fiLabel = string label
|
{ fiLabel = string label
|
||||||
, fiTooltip = tooltip
|
, fiTooltip = tooltip
|
||||||
, fiIdent = theId
|
, fiIdent = theId
|
||||||
, fiInput = addBody input
|
, fiInput = input
|
||||||
, fiErrors = case res of
|
, fiErrors = case res of
|
||||||
FormFailure [x] -> Just $ string x
|
FormFailure [x] -> Just $ string x
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
@ -246,9 +245,7 @@ boolInput n = GForm $ do
|
|||||||
Just "" -> FormSuccess False
|
Just "" -> FormSuccess False
|
||||||
Just "false" -> FormSuccess False
|
Just "false" -> FormSuccess False
|
||||||
Just _ -> FormSuccess True
|
Just _ -> FormSuccess True
|
||||||
let xml = addBody [$hamlet|
|
let xml = [$hamlet|%input#$n$!type=checkbox!name=$n$|]
|
||||||
%input#$n$!type=checkbox!name=$n$
|
|
||||||
|]
|
|
||||||
return (res, [xml], UrlEncoded)
|
return (res, [xml], UrlEncoded)
|
||||||
|
|
||||||
dayInput :: String -> FormInput sub master Day
|
dayInput :: String -> FormInput sub master Day
|
||||||
|
|||||||
@ -74,13 +74,13 @@ jqueryDayFieldProfile jds = FieldProfile
|
|||||||
. readMay
|
. readMay
|
||||||
, fpRender = show
|
, fpRender = show
|
||||||
, fpWidget = \theId name val isReq -> do
|
, fpWidget = \theId name val isReq -> do
|
||||||
addBody [$hamlet|
|
addHtml [$hamlet|
|
||||||
%input#$theId$!name=$name$!type=date!:isReq:required!value=$val$
|
%input#$theId$!name=$name$!type=date!:isReq:required!value=$val$
|
||||||
|]
|
|]
|
||||||
addScript' urlJqueryJs
|
addScript' urlJqueryJs
|
||||||
addScript' urlJqueryUiJs
|
addScript' urlJqueryUiJs
|
||||||
addStylesheet' urlJqueryUiCss
|
addStylesheet' urlJqueryUiCss
|
||||||
addJavascript [$julius|
|
addJulius [$julius|
|
||||||
$(function(){$("#%theId%").datepicker({
|
$(function(){$("#%theId%").datepicker({
|
||||||
dateFormat:'yy-mm-dd',
|
dateFormat:'yy-mm-dd',
|
||||||
changeMonth:%jsBool.jdsChangeMonth.jds%,
|
changeMonth:%jsBool.jdsChangeMonth.jds%,
|
||||||
@ -132,14 +132,14 @@ jqueryDayTimeFieldProfile = FieldProfile
|
|||||||
{ fpParse = parseUTCTime
|
{ fpParse = parseUTCTime
|
||||||
, fpRender = jqueryDayTimeUTCTime
|
, fpRender = jqueryDayTimeUTCTime
|
||||||
, fpWidget = \theId name val isReq -> do
|
, fpWidget = \theId name val isReq -> do
|
||||||
addBody [$hamlet|
|
addHtml [$hamlet|
|
||||||
%input#$theId$!name=$name$!:isReq:required!value=$val$
|
%input#$theId$!name=$name$!:isReq:required!value=$val$
|
||||||
|]
|
|]
|
||||||
addScript' urlJqueryJs
|
addScript' urlJqueryJs
|
||||||
addScript' urlJqueryUiJs
|
addScript' urlJqueryUiJs
|
||||||
addScript' urlJqueryUiDateTimePicker
|
addScript' urlJqueryUiDateTimePicker
|
||||||
addStylesheet' urlJqueryUiCss
|
addStylesheet' urlJqueryUiCss
|
||||||
addJavascript [$julius|
|
addJulius [$julius|
|
||||||
$(function(){$("#%theId%").datetimepicker({dateFormat : "yyyy/mm/dd h:MM TT"})});
|
$(function(){$("#%theId%").datetimepicker({dateFormat : "yyyy/mm/dd h:MM TT"})});
|
||||||
|]
|
|]
|
||||||
}
|
}
|
||||||
@ -176,13 +176,13 @@ jqueryAutocompleteFieldProfile src = FieldProfile
|
|||||||
{ fpParse = Right
|
{ fpParse = Right
|
||||||
, fpRender = id
|
, fpRender = id
|
||||||
, fpWidget = \theId name val isReq -> do
|
, fpWidget = \theId name val isReq -> do
|
||||||
addBody [$hamlet|
|
addHtml [$hamlet|
|
||||||
%input.autocomplete#$theId$!name=$name$!type=text!:isReq:required!value=$val$
|
%input.autocomplete#$theId$!name=$name$!type=text!:isReq:required!value=$val$
|
||||||
|]
|
|]
|
||||||
addScript' urlJqueryJs
|
addScript' urlJqueryJs
|
||||||
addScript' urlJqueryUiJs
|
addScript' urlJqueryUiJs
|
||||||
addStylesheet' urlJqueryUiCss
|
addStylesheet' urlJqueryUiCss
|
||||||
addJavascript [$julius|
|
addJulius [$julius|
|
||||||
$(function(){$("#%theId%").autocomplete({source:"@src@",minLength:2})});
|
$(function(){$("#%theId%").autocomplete({source:"@src@",minLength:2})});
|
||||||
|]
|
|]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,9 +35,9 @@ nicHtmlFieldProfile = FieldProfile
|
|||||||
{ fpParse = Right . preEscapedString . sanitizeXSS
|
{ fpParse = Right . preEscapedString . sanitizeXSS
|
||||||
, fpRender = lbsToChars . renderHtml
|
, fpRender = lbsToChars . renderHtml
|
||||||
, fpWidget = \theId name val _isReq -> do
|
, fpWidget = \theId name val _isReq -> do
|
||||||
addBody [$hamlet|%textarea.html#$theId$!name=$name$ $val$|]
|
addHtml [$hamlet|%textarea.html#$theId$!name=$name$ $val$|]
|
||||||
addScript' urlNicEdit
|
addScript' urlNicEdit
|
||||||
addJavascript [$julius|bkLib.onDomLoaded(function(){new nicEditor({fullPanel:true}).panelInstance("%theId%")});|]
|
addJulius [$julius|bkLib.onDomLoaded(function(){new nicEditor({fullPanel:true}).panelInstance("%theId%")});|]
|
||||||
}
|
}
|
||||||
|
|
||||||
addScript' :: (y -> Either (Route y) String) -> GWidget sub y ()
|
addScript' :: (y -> Either (Route y) String) -> GWidget sub y ()
|
||||||
|
|||||||
@ -35,7 +35,7 @@ intFieldProfile :: Integral i => FieldProfile sub y i
|
|||||||
intFieldProfile = FieldProfile
|
intFieldProfile = FieldProfile
|
||||||
{ fpParse = maybe (Left "Invalid integer") Right . readMayI
|
{ fpParse = maybe (Left "Invalid integer") Right . readMayI
|
||||||
, fpRender = showI
|
, fpRender = showI
|
||||||
, fpWidget = \theId name val isReq -> addBody [$hamlet|
|
, fpWidget = \theId name val isReq -> addHamlet [$hamlet|
|
||||||
%input#$theId$!name=$name$!type=number!:isReq:required!value=$val$
|
%input#$theId$!name=$name$!type=number!:isReq:required!value=$val$
|
||||||
|]
|
|]
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ doubleFieldProfile :: FieldProfile sub y Double
|
|||||||
doubleFieldProfile = FieldProfile
|
doubleFieldProfile = FieldProfile
|
||||||
{ fpParse = maybe (Left "Invalid number") Right . readMay
|
{ fpParse = maybe (Left "Invalid number") Right . readMay
|
||||||
, fpRender = show
|
, fpRender = show
|
||||||
, fpWidget = \theId name val isReq -> addBody [$hamlet|
|
, fpWidget = \theId name val isReq -> addHamlet [$hamlet|
|
||||||
%input#$theId$!name=$name$!type=text!:isReq:required!value=$val$
|
%input#$theId$!name=$name$!type=text!:isReq:required!value=$val$
|
||||||
|]
|
|]
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ dayFieldProfile :: FieldProfile sub y Day
|
|||||||
dayFieldProfile = FieldProfile
|
dayFieldProfile = FieldProfile
|
||||||
{ fpParse = parseDate
|
{ fpParse = parseDate
|
||||||
, fpRender = show
|
, fpRender = show
|
||||||
, fpWidget = \theId name val isReq -> addBody [$hamlet|
|
, fpWidget = \theId name val isReq -> addHamlet [$hamlet|
|
||||||
%input#$theId$!name=$name$!type=date!:isReq:required!value=$val$
|
%input#$theId$!name=$name$!type=date!:isReq:required!value=$val$
|
||||||
|]
|
|]
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ timeFieldProfile :: FieldProfile sub y TimeOfDay
|
|||||||
timeFieldProfile = FieldProfile
|
timeFieldProfile = FieldProfile
|
||||||
{ fpParse = parseTime
|
{ fpParse = parseTime
|
||||||
, fpRender = show
|
, fpRender = show
|
||||||
, fpWidget = \theId name val isReq -> addBody [$hamlet|
|
, fpWidget = \theId name val isReq -> addHamlet [$hamlet|
|
||||||
%input#$theId$!name=$name$!:isReq:required!value=$val$
|
%input#$theId$!name=$name$!:isReq:required!value=$val$
|
||||||
|]
|
|]
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ htmlFieldProfile :: FieldProfile sub y Html
|
|||||||
htmlFieldProfile = FieldProfile
|
htmlFieldProfile = FieldProfile
|
||||||
{ fpParse = Right . preEscapedString . sanitizeXSS
|
{ fpParse = Right . preEscapedString . sanitizeXSS
|
||||||
, fpRender = lbsToChars . renderHtml
|
, fpRender = lbsToChars . renderHtml
|
||||||
, fpWidget = \theId name val _isReq -> addBody [$hamlet|
|
, fpWidget = \theId name val _isReq -> addHamlet [$hamlet|
|
||||||
%textarea.html#$theId$!name=$name$ $val$
|
%textarea.html#$theId$!name=$name$ $val$
|
||||||
|]
|
|]
|
||||||
}
|
}
|
||||||
@ -102,7 +102,7 @@ textareaFieldProfile :: FieldProfile sub y Textarea
|
|||||||
textareaFieldProfile = FieldProfile
|
textareaFieldProfile = FieldProfile
|
||||||
{ fpParse = Right . Textarea
|
{ fpParse = Right . Textarea
|
||||||
, fpRender = unTextarea
|
, fpRender = unTextarea
|
||||||
, fpWidget = \theId name val _isReq -> addBody [$hamlet|
|
, fpWidget = \theId name val _isReq -> addHamlet [$hamlet|
|
||||||
%textarea#$theId$!name=$name$ $val$
|
%textarea#$theId$!name=$name$ $val$
|
||||||
|]
|
|]
|
||||||
}
|
}
|
||||||
@ -111,7 +111,7 @@ hiddenFieldProfile :: FieldProfile sub y String
|
|||||||
hiddenFieldProfile = FieldProfile
|
hiddenFieldProfile = FieldProfile
|
||||||
{ fpParse = Right
|
{ fpParse = Right
|
||||||
, fpRender = id
|
, fpRender = id
|
||||||
, fpWidget = \theId name val _isReq -> addBody [$hamlet|
|
, fpWidget = \theId name val _isReq -> addHamlet [$hamlet|
|
||||||
%input!type=hidden#$theId$!name=$name$!value=$val$
|
%input!type=hidden#$theId$!name=$name$!value=$val$
|
||||||
|]
|
|]
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ stringFieldProfile :: FieldProfile sub y String
|
|||||||
stringFieldProfile = FieldProfile
|
stringFieldProfile = FieldProfile
|
||||||
{ fpParse = Right
|
{ fpParse = Right
|
||||||
, fpRender = id
|
, fpRender = id
|
||||||
, fpWidget = \theId name val isReq -> addBody [$hamlet|
|
, fpWidget = \theId name val isReq -> addHamlet [$hamlet|
|
||||||
%input#$theId$!name=$name$!type=text!:isReq:required!value=$val$
|
%input#$theId$!name=$name$!type=text!:isReq:required!value=$val$
|
||||||
|]
|
|]
|
||||||
}
|
}
|
||||||
@ -169,7 +169,7 @@ emailFieldProfile = FieldProfile
|
|||||||
then Right s
|
then Right s
|
||||||
else Left "Invalid e-mail address"
|
else Left "Invalid e-mail address"
|
||||||
, fpRender = id
|
, fpRender = id
|
||||||
, fpWidget = \theId name val isReq -> addBody [$hamlet|
|
, fpWidget = \theId name val isReq -> addHamlet [$hamlet|
|
||||||
%input#$theId$!name=$name$!type=email!:isReq:required!value=$val$
|
%input#$theId$!name=$name$!type=email!:isReq:required!value=$val$
|
||||||
|]
|
|]
|
||||||
}
|
}
|
||||||
@ -180,7 +180,7 @@ urlFieldProfile = FieldProfile
|
|||||||
Nothing -> Left "Invalid URL"
|
Nothing -> Left "Invalid URL"
|
||||||
Just _ -> Right s
|
Just _ -> Right s
|
||||||
, fpRender = id
|
, fpRender = id
|
||||||
, fpWidget = \theId name val isReq -> addBody [$hamlet|
|
, fpWidget = \theId name val isReq -> addHamlet [$hamlet|
|
||||||
%input#$theId$!name=$name$!type=url!:isReq:required!value=$val$
|
%input#$theId$!name=$name$!type=url!:isReq:required!value=$val$
|
||||||
|]
|
|]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,7 +55,7 @@ getCrudListR = do
|
|||||||
toMaster <- getRouteToMaster
|
toMaster <- getRouteToMaster
|
||||||
defaultLayout $ do
|
defaultLayout $ do
|
||||||
setTitle "Items"
|
setTitle "Items"
|
||||||
addBody [$hamlet|
|
addWidget [$hamlet|
|
||||||
%h1 Items
|
%h1 Items
|
||||||
%ul
|
%ul
|
||||||
$forall items item
|
$forall items item
|
||||||
@ -115,7 +115,7 @@ getCrudDeleteR s = do
|
|||||||
toMaster <- getRouteToMaster
|
toMaster <- getRouteToMaster
|
||||||
defaultLayout $ do
|
defaultLayout $ do
|
||||||
setTitle "Confirm delete"
|
setTitle "Confirm delete"
|
||||||
addBody [$hamlet|
|
addWidget [$hamlet|
|
||||||
%form!method=post!action=@toMaster.CrudDeleteR.s@
|
%form!method=post!action=@toMaster.CrudDeleteR.s@
|
||||||
%h1 Really delete?
|
%h1 Really delete?
|
||||||
%p Do you really want to delete $itemTitle.item$?
|
%p Do you really want to delete $itemTitle.item$?
|
||||||
@ -156,10 +156,8 @@ crudHelper title me isPost = do
|
|||||||
$ toSinglePiece eid
|
$ toSinglePiece eid
|
||||||
_ -> return ()
|
_ -> return ()
|
||||||
defaultLayout $ do
|
defaultLayout $ do
|
||||||
wrapWidget form (wrapForm toMaster enctype)
|
|
||||||
setTitle $ string title
|
setTitle $ string title
|
||||||
where
|
addWidget [$hamlet|
|
||||||
wrapForm toMaster enctype form = [$hamlet|
|
|
||||||
%p
|
%p
|
||||||
%a!href=@toMaster.CrudListR@ Return to list
|
%a!href=@toMaster.CrudListR@ Return to list
|
||||||
%h1 $title$
|
%h1 $title$
|
||||||
|
|||||||
@ -10,21 +10,27 @@ module Yesod.Widget
|
|||||||
GWidget (..)
|
GWidget (..)
|
||||||
, liftHandler
|
, liftHandler
|
||||||
-- * Creating
|
-- * Creating
|
||||||
, newIdent
|
-- ** Head of page
|
||||||
, setTitle
|
, setTitle
|
||||||
, addStyle
|
, addHamletHead
|
||||||
|
, addHtmlHead
|
||||||
|
-- ** Body
|
||||||
|
, addHamlet
|
||||||
|
, addHtml
|
||||||
|
, addWidget
|
||||||
|
-- ** CSS
|
||||||
|
, addCassius
|
||||||
, addStylesheet
|
, addStylesheet
|
||||||
, addStylesheetRemote
|
, addStylesheetRemote
|
||||||
, addStylesheetEither
|
, addStylesheetEither
|
||||||
|
-- ** Javascript
|
||||||
|
, addJulius
|
||||||
, addScript
|
, addScript
|
||||||
, addScriptRemote
|
, addScriptRemote
|
||||||
, addScriptEither
|
, addScriptEither
|
||||||
, addHead
|
-- * Utilities
|
||||||
, addBody
|
|
||||||
, addJavascript
|
|
||||||
-- * Manipulating
|
|
||||||
, wrapWidget
|
|
||||||
, extractBody
|
, extractBody
|
||||||
|
, newIdent
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Data.Monoid
|
import Data.Monoid
|
||||||
@ -76,9 +82,9 @@ instance HamletValue (GWidget s m ()) where
|
|||||||
GWidget' { runGWidget' :: GWidget s m a }
|
GWidget' { runGWidget' :: GWidget s m a }
|
||||||
type HamletUrl (GWidget s m ()) = Route m
|
type HamletUrl (GWidget s m ()) = Route m
|
||||||
toHamletValue = runGWidget'
|
toHamletValue = runGWidget'
|
||||||
htmlToHamletMonad = GWidget' . addBody . const
|
htmlToHamletMonad = GWidget' . addHtml
|
||||||
urlToHamletMonad url params = GWidget' $
|
urlToHamletMonad url params = GWidget' $
|
||||||
addBody $ \r -> preEscapedString (r url params)
|
addHamlet $ \r -> preEscapedString (r url params)
|
||||||
fromHamletValue = GWidget'
|
fromHamletValue = GWidget'
|
||||||
instance Monad (HamletMonad (GWidget s m ())) where
|
instance Monad (HamletMonad (GWidget s m ())) where
|
||||||
return = GWidget' . return
|
return = GWidget' . return
|
||||||
@ -94,13 +100,26 @@ liftHandler = GWidget . lift . lift . lift . lift . lift . lift . lift . lift
|
|||||||
setTitle :: Html -> GWidget sub master ()
|
setTitle :: Html -> GWidget sub master ()
|
||||||
setTitle = GWidget . lift . tell . Last . Just . Title
|
setTitle = GWidget . lift . tell . Last . Just . Title
|
||||||
|
|
||||||
-- | Add some raw HTML to the head tag.
|
-- | Add a 'Hamlet' to the head tag.
|
||||||
addHead :: Hamlet (Route master) -> GWidget sub master ()
|
addHamletHead :: Hamlet (Route master) -> GWidget sub master ()
|
||||||
addHead = GWidget . lift . lift . lift . lift . lift . lift . tell . Head
|
addHamletHead = GWidget . lift . lift . lift . lift . lift . lift . tell . Head
|
||||||
|
|
||||||
-- | Add some raw HTML to the body tag.
|
-- | Add a 'Html' to the head tag.
|
||||||
addBody :: Hamlet (Route master) -> GWidget sub master ()
|
addHtmlHead :: Html -> GWidget sub master ()
|
||||||
addBody = GWidget . tell . Body
|
addHtmlHead = GWidget . lift . lift . lift . lift . lift . lift . tell . Head . const
|
||||||
|
|
||||||
|
-- | Add a 'Hamlet' to the body tag.
|
||||||
|
addHamlet :: Hamlet (Route master) -> GWidget sub master ()
|
||||||
|
addHamlet = GWidget . tell . Body
|
||||||
|
|
||||||
|
-- | Add a 'Html' to the body tag.
|
||||||
|
addHtml :: Html -> GWidget sub master ()
|
||||||
|
addHtml = GWidget . tell . Body . const
|
||||||
|
|
||||||
|
-- | Add another widget. This is defined as 'id', by can help with types, and
|
||||||
|
-- makes widget blocks look more consistent.
|
||||||
|
addWidget :: GWidget s m () -> GWidget s m ()
|
||||||
|
addWidget = id
|
||||||
|
|
||||||
-- | Get a unique identifier.
|
-- | Get a unique identifier.
|
||||||
newIdent :: GWidget sub master String
|
newIdent :: GWidget sub master String
|
||||||
@ -111,8 +130,8 @@ newIdent = GWidget $ lift $ lift $ lift $ lift $ lift $ lift $ lift $ do
|
|||||||
return $ "w" ++ show i'
|
return $ "w" ++ show i'
|
||||||
|
|
||||||
-- | Add some raw CSS to the style tag.
|
-- | Add some raw CSS to the style tag.
|
||||||
addStyle :: Cassius (Route master) -> GWidget sub master ()
|
addCassius :: Cassius (Route master) -> GWidget sub master ()
|
||||||
addStyle = GWidget . lift . lift . lift . lift . tell . Just
|
addCassius = GWidget . lift . lift . lift . lift . tell . Just
|
||||||
|
|
||||||
-- | Link to the specified local stylesheet.
|
-- | Link to the specified local stylesheet.
|
||||||
addStylesheet :: Route master -> GWidget sub master ()
|
addStylesheet :: Route master -> GWidget sub master ()
|
||||||
@ -139,18 +158,8 @@ addScriptRemote =
|
|||||||
GWidget . lift . lift . tell . toUnique . Script . Remote
|
GWidget . lift . lift . tell . toUnique . Script . Remote
|
||||||
|
|
||||||
-- | Include raw Javascript in the page's script tag.
|
-- | Include raw Javascript in the page's script tag.
|
||||||
addJavascript :: Julius (Route master) -> GWidget sub master ()
|
addJulius :: Julius (Route master) -> GWidget sub master ()
|
||||||
addJavascript = GWidget . lift . lift . lift . lift . lift. tell . Just
|
addJulius = GWidget . lift . lift . lift . lift . lift. tell . Just
|
||||||
|
|
||||||
-- | Modify the given 'GWidget' by wrapping the body tag HTML code with the
|
|
||||||
-- given function. You might also consider using 'extractBody'.
|
|
||||||
wrapWidget :: GWidget s m a
|
|
||||||
-> (Hamlet (Route m) -> Hamlet (Route m))
|
|
||||||
-> GWidget s m a
|
|
||||||
wrapWidget (GWidget w) wrap =
|
|
||||||
GWidget $ mapWriterT (fmap go) w
|
|
||||||
where
|
|
||||||
go (a, Body h) = (a, Body $ wrap h)
|
|
||||||
|
|
||||||
-- | Pull out the HTML tag contents and return it. Useful for performing some
|
-- | Pull out the HTML tag contents and return it. Useful for performing some
|
||||||
-- manipulations. It can be easier to use this sometimes than 'wrapWidget'.
|
-- manipulations. It can be easier to use this sometimes than 'wrapWidget'.
|
||||||
|
|||||||
@ -255,7 +255,7 @@ applyLayout' :: Yesod master
|
|||||||
-> GHandler sub master ChooseRep
|
-> GHandler sub master ChooseRep
|
||||||
applyLayout' title body = fmap chooseRep $ defaultLayout $ do
|
applyLayout' title body = fmap chooseRep $ defaultLayout $ do
|
||||||
setTitle title
|
setTitle title
|
||||||
addBody body
|
addHamlet body
|
||||||
|
|
||||||
-- | The default error handler for 'errorHandler'.
|
-- | The default error handler for 'errorHandler'.
|
||||||
defaultErrorHandler :: Yesod y => ErrorResponse -> GHandler sub y ChooseRep
|
defaultErrorHandler :: Yesod y => ErrorResponse -> GHandler sub y ChooseRep
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user