Params
is some "newtype" wrapper of Dict String String
, designed to be
used especially for rendering templates.
You usually don't need to use functions defined here directly except when
getting Params
value with fromDict
or fromList
.
A set of parameters for template function.
fromDict : Dict String String -> Params
Wrap a Dict
into Params
.
params =
fromDict <|
Dict.fromList
[ ( "css", "Cascading Style Sheet" )
, ( "html", "Hyper Text Markup Language" )
]
fromList : List ( String, String ) -> Params
Create Params
by converting given List
.
params =
fromList
[ ( "domain", "web development" )
, ( "type", "static" )
]
interpolate : String -> String -> Params -> String
Takes key and default value, returns associated value if one is found. Otherwise returns default value.
params =
fromList
[ ( "database", "MySQL" )
, ( "protocol", "HTTPS" )
]
params |> interpolate "protocol" "???" -- => "HTTPS"
params |> interpolate "size" "NOT FOUND" -- => "NOT FOUND"
get : String -> Params -> Maybe String
Try to get a value associated with given key from Params
.