Safe Haskell | None |
---|
Text.ProjectTemplate
- createTemplate :: Monad m => Conduit (FilePath, m ByteString) m ByteString
- unpackTemplate :: MonadThrow m => (FilePath -> Sink ByteString m ()) -> (Text -> Text) -> Sink ByteString m ()
- type FileReceiver m = FilePath -> Sink ByteString m ()
- receiveMem :: MonadWriter (Map FilePath LByteString) m => FileReceiver m
- receiveFS :: MonadResource m => FilePath -> FileReceiver m
- data ProjectTemplateException
Create a template
createTemplate :: Monad m => Conduit (FilePath, m ByteString) m ByteString
Create a template file from a stream of file/contents combinations.
Since 0.1.0
Unpack a template
Arguments
:: MonadThrow m | |
=> (FilePath -> Sink ByteString m ()) | receive individual files |
-> (Text -> Text) | fix each input line, good for variables |
-> Sink ByteString m () |
Unpack a template to some destination. Destination is provided by the first argument.
The second argument allows you to modify the incoming stream, usually to replace variables. For example, to replace PROJECTNAME with myproject, you could use:
Data.Text.replace "PROJECTNAME" "myproject"
Note that this will affect both file contents and file names.
Since 0.1.0
Receivers
type FileReceiver m = FilePath -> Sink ByteString m ()
The first argument to unpackTemplate
, specifying how to receive a file.
Since 0.1.0
receiveMem :: MonadWriter (Map FilePath LByteString) m => FileReceiver m
Receive files to a Writer
monad in memory.
execWriter $ runExceptionT_ $ src $$ unpackTemplate receiveMem id
Since 0.1.0
Arguments
:: MonadResource m | |
=> FilePath | root |
-> FileReceiver m |
Receive files to the given folder on the filesystem.
unpackTemplate (receiveFS "some-destination") (T.replace "PROJECTNAME" "foo")
Since 0.1.0
Exceptions
Exceptions that can be thrown.
Since 0.1.0
Constructors
InvalidInput Text | |
BinaryLoopNeedsOneLine |