globFilePackage which provides absolute globFile paths within package
This commit is contained in:
parent
8845483c20
commit
b73a95c8b6
@ -5,6 +5,7 @@
|
|||||||
module Yesod.Default.Util
|
module Yesod.Default.Util
|
||||||
( addStaticContentExternal
|
( addStaticContentExternal
|
||||||
, globFile
|
, globFile
|
||||||
|
, globFilePackage
|
||||||
, widgetFileNoReload
|
, widgetFileNoReload
|
||||||
, widgetFileReload
|
, widgetFileReload
|
||||||
, TemplateLanguage (..)
|
, TemplateLanguage (..)
|
||||||
@ -15,6 +16,7 @@ module Yesod.Default.Util
|
|||||||
) where
|
) where
|
||||||
|
|
||||||
import qualified Data.ByteString.Lazy as L
|
import qualified Data.ByteString.Lazy as L
|
||||||
|
import Data.FileEmbed (makeRelativeToProject)
|
||||||
import Data.Text (Text, pack, unpack)
|
import Data.Text (Text, pack, unpack)
|
||||||
import Yesod.Core -- purposely using complete import so that Haddock will see addStaticContent
|
import Yesod.Core -- purposely using complete import so that Haddock will see addStaticContent
|
||||||
import Control.Monad (when, unless)
|
import Control.Monad (when, unless)
|
||||||
@ -64,6 +66,10 @@ addStaticContentExternal minify hash staticDir toRoute ext' _ content = do
|
|||||||
globFile :: String -> String -> FilePath
|
globFile :: String -> String -> FilePath
|
||||||
globFile kind x = "templates/" ++ x ++ "." ++ kind
|
globFile kind x = "templates/" ++ x ++ "." ++ kind
|
||||||
|
|
||||||
|
-- | `globFile` but returned path is absolute and within the package the Q Exp is evaluated
|
||||||
|
globFilePackage :: String -> String -> Q FilePath
|
||||||
|
globFilePackage = (makeRelativeToProject <$>) . globFile
|
||||||
|
|
||||||
data TemplateLanguage = TemplateLanguage
|
data TemplateLanguage = TemplateLanguage
|
||||||
{ tlRequiresToWidget :: Bool
|
{ tlRequiresToWidget :: Bool
|
||||||
, tlExtension :: String
|
, tlExtension :: String
|
||||||
|
|||||||
@ -25,6 +25,7 @@ library
|
|||||||
, data-default-class
|
, data-default-class
|
||||||
, directory
|
, directory
|
||||||
, fast-logger
|
, fast-logger
|
||||||
|
, file-embed
|
||||||
, monad-logger
|
, monad-logger
|
||||||
, shakespeare
|
, shakespeare
|
||||||
, streaming-commons
|
, streaming-commons
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user