Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ToWidget instances for strict text, lazy text, and text builder #1310

Merged
merged 1 commit into from
Nov 30, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions yesod-core/Yesod/Core/Widget.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import qualified Text.Hamlet as NP
import Data.Text.Lazy.Builder (fromLazyText)
import Text.Blaze.Html (toHtml, preEscapedToMarkup)
import qualified Data.Text.Lazy as TL
import qualified Data.Text.Lazy.Builder as TB

import Yesod.Core.Types
import Yesod.Core.Class.Handler
Expand Down Expand Up @@ -100,6 +101,12 @@ instance (site' ~ site, IO ~ m, a ~ ()) => ToWidget site' (WidgetT site m a) whe
toWidget = liftWidgetT
instance ToWidget site Html where
toWidget = toWidget . const
instance ToWidget site Text where
toWidget = toWidget . toHtml
instance ToWidget site TL.Text where
toWidget = toWidget . toHtml
instance ToWidget site TB.Builder where
toWidget = toWidget . toHtml

-- | Allows adding some CSS to the page with a specific media type.
--
Expand Down