Changes to Css and Javascript datatypes

This commit is contained in:
Michael 2011-01-05 23:47:59 +02:00
parent 055da0febe
commit 06db8b9508
2 changed files with 8 additions and 8 deletions

View File

@ -50,7 +50,9 @@ import Text.Hamlet
import Text.Cassius
import Text.Julius
import Web.Routes
import Blaze.ByteString.Builder (toLazyByteString)
import Text.Blaze (preEscapedLazyText)
import Data.Text.Lazy.Builder (toLazyText)
import Data.Text.Lazy.Encoding (encodeUtf8)
#if TEST
import Test.Framework (testGroup, Test)
@ -382,12 +384,10 @@ widgetToPageContent (GWidget w) = do
let scripts = map (locationToHamlet . unScript) $ runUniqueList scripts'
let stylesheets = map (locationToHamlet . unStylesheet)
$ runUniqueList stylesheets'
-- FIXME change hamlet: cassius and julius should be structured datatypes so we don't need to do this
let unsafeLazyByteString = mconcat . map unsafeByteString . L.toChunks
let cssToHtml (Css b) = unsafeLazyByteString $ toLazyByteString b
let cssToHtml = preEscapedLazyText . renderCss
celper :: Cassius url -> Hamlet url
celper = fmap cssToHtml
jsToHtml (Javascript b) = unsafeLazyByteString $ toLazyByteString b
jsToHtml (Javascript b) = preEscapedLazyText $ toLazyText b
jelper :: Julius url -> Hamlet url
jelper = fmap jsToHtml
@ -402,14 +402,14 @@ widgetToPageContent (GWidget w) = do
Nothing -> return Nothing
Just s -> do
x <- addStaticContent "css" "text/css; charset=utf-8"
$ renderCassius render s
$ encodeUtf8 $ renderCassius render s
return $ renderLoc x
jsLoc <-
case jscript of
Nothing -> return Nothing
Just s -> do
x <- addStaticContent "js" "text/javascript; charset=utf-8"
$ renderJulius render s
$ encodeUtf8 $ renderJulius render s
return $ renderLoc x
let head'' =

View File

@ -47,7 +47,7 @@ library
, monad-peel >= 0.1 && < 0.2
, enumerator >= 0.4 && < 0.5
, cookie >= 0.0 && < 0.1
, blaze-html >= 0.3.0.4 && < 0.4
, blaze-html >= 0.3.2.1 && < 0.4
exposed-modules: Yesod.Content
Yesod.Core
Yesod.Dispatch