pencil-1.0.1: Static site generator

Safe HaskellNone
LanguageHaskell2010

Pencil.Env

Description

Functions that manipulate the environment.

Synopsis

Documentation

data Value Source #

Represents the data types found in an environment.

This includes at least Aeson Value types, plus other useful ones.

Instances
Eq Value Source # 
Instance details

Defined in Pencil.Env.Internal

Methods

(==) :: Value -> Value -> Bool #

(/=) :: Value -> Value -> Bool #

Show Value Source # 
Instance details

Defined in Pencil.Env.Internal

Methods

showsPrec :: Int -> Value -> ShowS #

show :: Value -> String #

showList :: [Value] -> ShowS #

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) (render page)

Alternatively, use local, which is re-exported in the Pencil module.

insert Source #

Arguments

:: Text

Environment variable name.

-> Value

Value to insert.

-> Env

Environment to modify.

-> Env 

Inserts Value into the given Env.

insertText Source #

Arguments

:: Text

Environment variable name.

-> Text

Text to insert.

-> Env

Environment to modify.

-> Env 

Inserts text into the given Env.

env <- asks getEnv
insertText "title" "My Awesome Website" env

adjust Source #

Arguments

:: (Value -> Value) 
-> Text

Environment variable name.

-> Env 
-> 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.

toTextRss :: Value -> Text Source #

A version of toText that renders Value acceptable for an RSS feed.

  • Dates are rendered in the RFC 822 format.
  • Everything else defaults to the toText implementation.

You'll probably want to also use escapeXml to render an RSS feed.

arrayContainsText :: Text -> Value -> Bool Source #

Returns true if the given Value is a VArray that contains the given text.

dateOrdering :: Value -> Value -> Ordering Source #

Sort by newest first.

maybeOrdering :: (Value -> Value -> Ordering) -> Maybe Value -> Maybe Value -> Ordering Source #

Defines an ordering for possibly-missing Value. Nothings are ordered last.