Safe Haskell | None |
---|---|
Language | GHC2021 |
Ondim.Loading
Contents
Description
This module defines helper functions for loading templates from a list of
directories, optionally using fsnotify
for watching and reloading on file
changes. There is also a helper for loading templates at compile-time via the
file-embed
package.
Synopsis
- loadTemplates :: [LoadConfig n] -> [(FilePath, Maybe FilePath)] -> Logger -> IO (OndimState n)
- loadTemplatesDynamic :: [LoadConfig n] -> [(FilePath, Maybe FilePath)] -> Logger -> IO (OndimState n, (OndimState n -> IO ()) -> IO ())
- loadTemplatesEmbed :: String -> [LoadConfig n] -> [(FilePath, ByteString)] -> OndimState n
- data LoadConfig n = LoadConfig {
- patterns :: [FilePattern]
- loadFn :: LoadFn n
- initialState :: OndimState n
- type LoadFn n = FilePath -> LByteString -> NamespaceItem n
- loadFnSimple :: OndimNode a => (FilePath -> LByteString -> Either String a) -> LoadFn n
- newtype TemplateLoadingException = TemplateLoadingException String
Documentation
loadTemplates :: [LoadConfig n] -> [(FilePath, Maybe FilePath)] -> Logger -> IO (OndimState n) Source #
Load templates from a list of directories in descending order of priority.
Arguments
:: [LoadConfig n] | Loading configurations |
-> [(FilePath, Maybe FilePath)] | Places to look for templates and their (optional) mount point, in descending order of priority. |
-> Logger | Logger |
-> IO (OndimState n, (OndimState n -> IO ()) -> IO ()) |
Load templates from a list of directories in descending order of priority, and return the inital state and a watcher action that takes a handler to update the state when templates get updated on disk.
loadTemplatesEmbed :: String -> [LoadConfig n] -> [(FilePath, ByteString)] -> OndimState n Source #
Load templates in pure code from a list of filepaths and bytestrings. Meant
to be used with the file-embed
package.
"Advanced" usage
There are default LoadConfig
s inside each target's respective
modules, but you can also use the definitions below to customize them if
you wish.
data LoadConfig n Source #
Configuration for loading templates of a specific type.
Constructors
LoadConfig | |
Fields
|
Arguments
= FilePath | Filepath |
-> LByteString | File contents |
-> NamespaceItem n | Resulting state data |
A recipe to create templates from file contents.
loadFnSimple :: OndimNode a => (FilePath -> LByteString -> Either String a) -> LoadFn n Source #
Default way to load a template. In most cases you should use this recipe.
newtype TemplateLoadingException Source #
Some template loading (impure) exception.
Constructors
TemplateLoadingException String |
Instances
Exception TemplateLoadingException Source # | |
Defined in Ondim.Loading | |
Show TemplateLoadingException Source # | |
Defined in Ondim.Loading Methods showsPrec :: Int -> TemplateLoadingException -> ShowS # show :: TemplateLoadingException -> String # showList :: [TemplateLoadingException] -> ShowS # | |
Eq TemplateLoadingException Source # | |
Defined in Ondim.Loading Methods (==) :: TemplateLoadingException -> TemplateLoadingException -> Bool # (/=) :: TemplateLoadingException -> TemplateLoadingException -> Bool # |