Copyright | (c) 2019-2022 Vaclav Svejcar |
---|---|
License | BSD-3-Clause |
Maintainer | vaclav.svejcar@gmail.com |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
TemplateRef
data type represents reference to template file, either local or
remote, which can be later opened/downloaded and parsed into template.
Synopsis
Data Types
data TemplateRef Source #
Reference to the template (e.g. local file, URI address).
InlineRef Text | |
LocalTemplateRef FilePath | template path on local file system |
UriTemplateRef URI | remote template URI adress |
BuiltInRef LicenseType FileType |
Instances
Eq TemplateRef Source # | |
Defined in Headroom.Template.TemplateRef (==) :: TemplateRef -> TemplateRef -> Bool # (/=) :: TemplateRef -> TemplateRef -> Bool # | |
Ord TemplateRef Source # | |
Defined in Headroom.Template.TemplateRef compare :: TemplateRef -> TemplateRef -> Ordering # (<) :: TemplateRef -> TemplateRef -> Bool # (<=) :: TemplateRef -> TemplateRef -> Bool # (>) :: TemplateRef -> TemplateRef -> Bool # (>=) :: TemplateRef -> TemplateRef -> Bool # max :: TemplateRef -> TemplateRef -> TemplateRef # min :: TemplateRef -> TemplateRef -> TemplateRef # | |
Show TemplateRef Source # | |
Defined in Headroom.Template.TemplateRef showsPrec :: Int -> TemplateRef -> ShowS # show :: TemplateRef -> String # showList :: [TemplateRef] -> ShowS # | |
FromJSON TemplateRef Source # | |
Defined in Headroom.Template.TemplateRef parseJSON :: Value -> Parser TemplateRef # parseJSONList :: Value -> Parser [TemplateRef] # |
Constructor Functions
:: MonadThrow m | |
=> Text | input text |
-> m TemplateRef | created |
Creates a TemplateRef
from given text. If the raw text appears to be
valid URL with either http
or https
as protocol, it considers it as
UriTemplateRef
, otherwise it creates LocalTemplateRef
.
>>>
mkTemplateRef "/path/to/haskell.mustache" :: Maybe TemplateRef
Just (LocalTemplateRef "/path/to/haskell.mustache")
>>>
mkTemplateRef "https://foo.bar/haskell.mustache" :: Maybe TemplateRef
Just (UriTemplateRef (URI {uriScheme = Just "https", uriAuthority = Right (Authority {authUserInfo = Nothing, authHost = "foo.bar", authPort = Nothing}), uriPath = Just (False,"haskell.mustache" :| []), uriQuery = [], uriFragment = Nothing}))
Public Functions
:: TemplateRef |
|
-> Text | rendered text |
Renders given TemplateRef
into human-friendly text.
Error Types
data TemplateRefError Source #
Error related to template references.
UnrecognizedTemplateName Text | not a valid format for template name |
UnsupportedUriProtocol Text Text | URI protocol not supported |
Instances
Eq TemplateRefError Source # | |
Defined in Headroom.Template.TemplateRef (==) :: TemplateRefError -> TemplateRefError -> Bool # (/=) :: TemplateRefError -> TemplateRefError -> Bool # | |
Show TemplateRefError Source # | |
Defined in Headroom.Template.TemplateRef showsPrec :: Int -> TemplateRefError -> ShowS # show :: TemplateRefError -> String # showList :: [TemplateRefError] -> ShowS # | |
Exception TemplateRefError Source # | |
Defined in Headroom.Template.TemplateRef |