| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Pencil.Env
Description
Functions that manipulate the environment.
Synopsis
- data Value
- withEnv :: Env -> PencilApp a -> PencilApp a
- insert :: Text -> Value -> Env -> Env
- insertText :: Text -> Text -> Env -> Env
- adjust :: (Value -> Value) -> Text -> Env -> Env
- merge :: Env -> Env -> Env
- toText :: Value -> Text
- toTextRss :: Value -> Text
- arrayContainsText :: Text -> Value -> Bool
- dateOrdering :: Value -> Value -> Ordering
- maybeOrdering :: (Value -> Value -> Ordering) -> Maybe Value -> Maybe Value -> Ordering
Documentation
Represents the data types found in an environment.
This includes at least Aeson Value types, plus other
useful ones.
withEnv :: Env -> PencilApp a -> PencilApp a Source #
Runs the computation with the given environment. This is useful when you
want to render a Page or Structure with a modified environment.
withEnv (insertText"newvar" "newval" env) (renderpage)
Alternatively, use local, which is re-exported in the Pencil module.
Arguments
| :: Text | Environment variable name. |
| -> Value |
|
| -> Env | Environment to modify. |
| -> Env |
Inserts Value into the given Env.
Inserts text into the given Env.
env <- asks getEnv insertText "title" "My Awesome Website" env
Modifies a variable in the given environment.
merge :: Env -> Env -> Env Source #
Merges two Envs together, biased towards the left-hand Env on duplicates.
toText :: Value -> Text Source #
Renders environment value for human consumption. This is the default one.