Created
June 6, 2015 14:09
-
-
Save sheganinans/5cbc0120395212034ef7 to your computer and use it in GitHub Desktop.
Yesod <> Clay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DoAndIfThenElse #-} | |
module Clay.Main where | |
import Control.Monad (mapM_) | |
import Data.Bool (Bool (..)) | |
import Data.Monoid ((<>)) | |
import Data.String (String) | |
import Data.Text.Lazy (Text) | |
import Data.Text.Lazy.IO (writeFile) | |
import Data.Tuple (uncurry) | |
import System.Directory (getCurrentDirectory) | |
import System.IO (IO,FilePath) | |
import Clay | |
import Clay.SampleCss (sampleCss) | |
cssList :: [(FilePath, Css)] | |
cssList = | |
[ ( "sample-css" , sampleCss ) | |
] | |
ifPretty :: Bool | |
ifPretty = True | |
main :: IO () | |
main = do | |
if ifPretty | |
then mapM_ (uncurry writePrettyCss) cssList | |
else mapM_ (uncurry writeCompactCss) cssList | |
writePrettyCss, writeCompactCss :: String -> Css -> IO () | |
writePrettyCss = writeCss renderPretty | |
writeCompactCss = writeCss renderCompact | |
writeCss :: (Css -> Text) -> String -> Css -> IO () | |
writeCss f s c = do | |
currDir <- getCurrentDirectory | |
writeFile (currDir <> "/static/css/" <> s <> ".css") (f c) | |
renderPretty, renderCompact :: Css -> Text | |
renderPretty = renderWith pretty [] | |
renderCompact = renderWith compact [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Clay.SampleCss where | |
import Clay | |
import Control.Monad (return) | |
sampleCss :: Css | |
sampleCss = body ? do ; return () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment