Skip to content

Instantly share code, notes, and snippets.

@sheganinans
Created June 6, 2015 14:09
Show Gist options
  • Save sheganinans/5cbc0120395212034ef7 to your computer and use it in GitHub Desktop.
Save sheganinans/5cbc0120395212034ef7 to your computer and use it in GitHub Desktop.
Yesod <> Clay
{-# 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 []
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