| Copyright | (c) 2019-2020 Vaclav Svejcar |
|---|---|
| License | BSD-3-Clause |
| Maintainer | vaclav.svejcar@gmail.com |
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | None |
| Language | Haskell2010 |
Headroom.Variables
Description
Module containing costructor and useful functions for the Variables data type.
Synopsis
- mkVariables :: [(Text, Text)] -> Variables
- dynamicVariables :: CurrentYear -> Variables
- parseVariables :: MonadThrow m => [Text] -> m Variables
- compileVariables :: MonadThrow m => Variables -> m Variables
Constructing Variables
Constructor function for Variables data type.
>>>mkVariables [("key1", "value1")]Variables (fromList [("key1","value1")])
Arguments
| :: CurrentYear | current year |
| -> Variables | map of dynamic variables |
Dynamic variables that are common for all parsed files.
_current_year- current year
Parsing Variables
Arguments
| :: MonadThrow m | |
| => [Text] | list of raw variables |
| -> m Variables | parsed variables |
Parses variables from raw input in key=value format.
>>>parseVariables ["key1=value1"]Variables (fromList [("key1","value1")])
Processing Variables
Arguments
| :: MonadThrow m | |
| => Variables | input variables to compile |
| -> m Variables | compiled variables |
Compiles variable values that are itself mini-templates, where their variables will be substituted by other variable values (if possible). Note that recursive variable reference and/or cyclic references are not supported.
>>>compileVariables $ mkVariables [("name", "John"), ("msg", "Hello, {{ name }}")]Variables (fromList [("msg","Hello, John"),("name","John")])