headroom-0.4.3.0: License Header Manager
Copyright(c) 2019-2022 Vaclav Svejcar
LicenseBSD-3-Clause
Maintainervaclav.svejcar@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Headroom.Template.TemplateRef

Description

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

Constructors

InlineRef Text 
LocalTemplateRef FilePath

template path on local file system

UriTemplateRef URI

remote template URI adress

BuiltInRef LicenseType FileType 

Constructor Functions

mkTemplateRef Source #

Arguments

:: MonadThrow m 
=> Text

input text

-> m TemplateRef

created TemplateRef (or error)

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

renderRef Source #

Arguments

:: TemplateRef

TemplateRef to render

-> Text

rendered text

Renders given TemplateRef into human-friendly text.

Error Types