add widgetFileJsCss for exact cs/js specification
I can set it to coffeescript.
widgetFile = Yesod.Default.Util.widgetFileJsCss $ globFile
("coffee", coffeeFileReload) ("cassius", cassiusFileReload)
Should we put code like this as the scaffold default?
Obviously, we can keep it defaulted to "julius"
This commit is contained in:
parent
ffaa1d6a32
commit
22200b910b
@ -7,6 +7,7 @@ module Yesod.Default.Util
|
|||||||
, globFile
|
, globFile
|
||||||
, widgetFileNoReload
|
, widgetFileNoReload
|
||||||
, widgetFileReload
|
, widgetFileReload
|
||||||
|
, widgetFileJsCss
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Monad.IO.Class (liftIO)
|
import Control.Monad.IO.Class (liftIO)
|
||||||
@ -72,8 +73,21 @@ widgetFileReload x = do
|
|||||||
let l = whenExists x "lucius" luciusFileReload
|
let l = whenExists x "lucius" luciusFileReload
|
||||||
[|$h >> addCassius $c >> addJulius $j >> addLucius $l|]
|
[|$h >> addCassius $c >> addJulius $j >> addLucius $l|]
|
||||||
|
|
||||||
|
widgetFileJsCss :: (String, FilePath -> Q Exp) -- ^ Css file extenstion and loading function. example: ("cassius", cassiusFileReload)
|
||||||
|
-> (String, FilePath -> Q Exp) -- ^ Css file extenstion and loading function. example: ("julius", juliusFileReload)
|
||||||
|
-> FilePath -> Q Exp
|
||||||
|
widgetFileJsCss (jsExt, jsLoad) (csExt, csLoad) x = do
|
||||||
|
let h = whenExists x "hamlet" whamletFile
|
||||||
|
let c = whenExists x csExt csLoad
|
||||||
|
let j = whenExists x jsExt jsLoad
|
||||||
|
[|$h >> addCassius $c >> addJulius $j|]
|
||||||
|
|
||||||
whenExists :: String -> String -> (FilePath -> Q Exp) -> Q Exp
|
whenExists :: String -> String -> (FilePath -> Q Exp) -> Q Exp
|
||||||
whenExists x glob f = do
|
whenExists = warnUnlessExists False
|
||||||
|
|
||||||
|
warnUnlessExists :: Bool -> String -> String -> (FilePath -> Q Exp) -> Q Exp
|
||||||
|
warnUnlessExists shouldWarn x glob f = do
|
||||||
let fn = globFile glob x
|
let fn = globFile glob x
|
||||||
e <- qRunIO $ doesFileExist fn
|
e <- qRunIO $ doesFileExist fn
|
||||||
|
unless (shouldWarn && e) $ qRunIO $ putStrLn $ "widget file not found: " ++ fn
|
||||||
if e then f fn else [|mempty|]
|
if e then f fn else [|mempty|]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user