ede-0.3.4.0: Templating language with similar syntax and features to Liquid or Jinja2.
Copyright(c) 2013-2022 Brendan Hay <brendan.g.hay@gmail.com>
LicenseThis Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. A copy of the MPL can be found in the LICENSE file or you can obtain it at http://mozilla.org/MPL/2.0/.
MaintainerBrendan Hay <brendan.g.hay@gmail.com>
Stabilityexperimental
Portabilitynon-portable (GHC extensions)
Safe HaskellSafe-Inferred
LanguageHaskell2010

Text.EDE.Filters

Description

The means to construct your own filters.

Synopsis

Prelude

The default filters available to a template are documented by the subsequent categories.

These filters cannot be overriden and attempting to supply your own filters to renderWith will cause the similarly named filters to disappear when they are merged with the prelude during evaluation. (See: union)

Boolean

! :: Bool -> Bool
See: not
&& :: Bool -> Bool -> Bool
|| :: Bool -> Bool -> Bool

Equality

== :: a -> a -> Bool
!= :: a -> a -> Bool
See: /=

Relational

> :: a -> a -> Bool
>= :: a -> a -> Bool
<= :: a -> a -> Bool
< :: a -> a -> Bool

Numeric

+ :: Scientific -> Scientific -> Scientific
- :: Scientific -> Scientific -> Scientific
* :: Scientific -> Scientific -> Scientific
abs :: Scientific -> Scientific
negate :: Scientific -> Scientific
signum :: Scientific -> Scientific

Fractional

ceiling :: Scientific -> Scientific
floor :: Scientific -> Scientific
round :: Scientific -> Scientific
truncate :: Scientific -> Scientific

Textual

dropLower :: Text -> Text
Drop preceding lowercase characters.
dropUpper :: Text -> Text
Drop preceding uppercase characters.
indentLines :: Text -> Text
prependLines :: Text -> Text
justifyLeft :: Text -> Text
Using whitespace as fill character.
justifyRight :: Text -> Text
Using whitespace as fill character.
center :: Text -> Text
Using whitespace as fill character.
replace :: Text -> Text
remove :: Text -> Text
Shortcut for: replace(pattern, "")
splitWords :: Text -> Text
strip :: Text -> Text
stripPrefix :: Text -> Text
stripSuffix :: Text -> Text
stripStart :: Text -> Text
stripEnd :: Text -> Text
takeWord :: Text -> Text
dropWord :: Text -> Text
lowerHead :: Text -> Text
upperHead :: Text -> Text
toCamel :: Text -> Text
toEllipsis :: Text -> Text
toEllipsisWith :: Text -> Text
toPascal :: Text -> Text
toSnake :: Text -> Text
toSpinal :: Text -> Text
toTitle :: Text -> Text
toTrain :: Text -> Text
toLower :: Text -> Text
toUpper :: Text -> Text
toOrdinal :: Scientific -> Text

Collection

length :: Collection -> Scientific
See: Text.length, Vector.length, HashMap.size
empty :: Collection -> Bool
See: Text.null, Vector.null, HashMap.null
reverse :: Collection -> Scientific
See: Text.reverse, Vector.reverse
head :: Collection -> Scientific
See: Text.head, Vector.head
last :: Collection -> Scientific
See: Text.last, Vector.last
tail :: Collection -> Scientific
See: Text.tail, Vector.tail
init :: Collection -> Scientific
See: Text.init, Vector.init
keys :: Collection -> Scientific
elems :: Collection -> Scientific

Polymorphic

show :: a -> Text

Constructing filters

data Term Source #

A HOAS representation of (possibly partially applied) values in the environment.

Constructors

TVal !Value 
TLam (Term -> Result Term) 

Instances

Instances details
Quote Term Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

quote :: Id -> Int -> Term -> Term Source #

AnsiPretty Term Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

apretty :: Term -> AnsiDoc Source #

Classes

class Quote a where Source #

Minimal complete definition

Nothing

Methods

quote :: Id -> Int -> a -> Term Source #

default quote :: ToJSON a => Id -> Int -> a -> Term Source #

Instances

Instances details
Quote Value Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

quote :: Id -> Int -> Value -> Term Source #

Quote Term Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

quote :: Id -> Int -> Term -> Term Source #

Quote Scientific Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

quote :: Id -> Int -> Scientific -> Term Source #

Quote Text Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

quote :: Id -> Int -> Text -> Term Source #

Quote Builder Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

quote :: Id -> Int -> Builder -> Term Source #

Quote Text Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

quote :: Id -> Int -> Text -> Term Source #

Quote Integer Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

quote :: Id -> Int -> Integer -> Term Source #

Quote Bool Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

quote :: Id -> Int -> Bool -> Term Source #

Quote Double Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

quote :: Id -> Int -> Double -> Term Source #

Quote Int Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

quote :: Id -> Int -> Int -> Term Source #

Quote (KeyMap Value) Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

quote :: Id -> Int -> KeyMap Value -> Term Source #

Quote (Vector Value) Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

quote :: Id -> Int -> Vector Value -> Term Source #

Quote [Value] Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

quote :: Id -> Int -> [Value] -> Term Source #

Quote [Text] Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

quote :: Id -> Int -> [Text] -> Term Source #

Quote (HashMap Text Value) Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

quote :: Id -> Int -> HashMap Text Value -> Term Source #

(Unquote a, Quote b) => Quote (a -> b) Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

quote :: Id -> Int -> (a -> b) -> Term Source #

class Unquote a where Source #

Minimal complete definition

Nothing

Methods

unquote :: Id -> Int -> Term -> Result a Source #

default unquote :: FromJSON a => Id -> Int -> Term -> Result a Source #

Instances

Instances details
Unquote Value Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

unquote :: Id -> Int -> Term -> Result Value Source #

Unquote Collection Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

unquote :: Id -> Int -> Term -> Result Collection Source #

Unquote Scientific Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

unquote :: Id -> Int -> Term -> Result Scientific Source #

Unquote Text Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

unquote :: Id -> Int -> Term -> Result Text Source #

Unquote Text Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

unquote :: Id -> Int -> Term -> Result Text Source #

Unquote Integer Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

unquote :: Id -> Int -> Term -> Result Integer Source #

Unquote Bool Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

unquote :: Id -> Int -> Term -> Result Bool Source #

Unquote Double Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

unquote :: Id -> Int -> Term -> Result Double Source #

Unquote Int Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

unquote :: Id -> Int -> Term -> Result Int Source #

Unquote (KeyMap Value) Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

unquote :: Id -> Int -> Term -> Result (KeyMap Value) Source #

Unquote (Vector Value) Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

unquote :: Id -> Int -> Term -> Result (Vector Value) Source #

Unquote [Text] Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

unquote :: Id -> Int -> Term -> Result [Text] Source #

Unquote (HashMap Text Value) Source # 
Instance details

Defined in Text.EDE.Internal.Quoting

Methods

unquote :: Id -> Int -> Term -> Result (HashMap Text Value) Source #

Restricted quoters

(@:) :: Quote a => Id -> a -> (Id, Term) Source #

qapply :: Delta -> Term -> Term -> Result Term Source #

Fully apply two Terms.

qpoly2 :: Quote a => Id -> (Value -> Value -> a) -> (Id, Term) Source #

Quote a binary function which takes the most general binding value.

qnum1 :: Id -> (Scientific -> Scientific) -> (Id, Term) Source #

Quote an unary numeric function.

qnum2 :: Quote a => Id -> (Scientific -> Scientific -> a) -> (Id, Term) Source #

Quote a binary numeric function.

qcol1 :: (Quote a, Quote b, Quote c) => Id -> (Text -> a) -> (HashMap Text Value -> b) -> (Vector Value -> c) -> (Id, Term) Source #

Quote a comprehensive set of unary functions to create a binding that supports all collection types.

Errors

argumentErr :: Pretty a => Id -> Int -> a -> Result b Source #