ondim-0.1.0.0
Safe HaskellNone
LanguageGHC2021

Ondim.Loading

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

Documentation

loadTemplates :: [LoadConfig n] -> [(FilePath, Maybe FilePath)] -> Logger -> IO (OndimState n) Source #

Load templates from a list of directories in descending order of priority.

loadTemplatesDynamic Source #

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 LoadConfigs 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

type LoadFn n Source #

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.