-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A template DSL library -- -- A minimalistic, Mustache-like syntax, truly logic-less, pure Text -- template DSL library @package glabrous @version 2.0.0 module Text.Glabrous.Types data Token Tag :: !Text -> Token Literal :: !Text -> Token newtype Template Template :: [Token] -> Template [content] :: Template -> [Token] newtype Context Context :: HashMap Text Text -> Context [variables] :: Context -> HashMap Text Text data Result Final :: !Text -> Result Partial :: !Template -> !Context -> Result [template] :: Result -> !Template [context] :: Result -> !Context instance GHC.Show.Show Text.Glabrous.Types.Result instance GHC.Classes.Eq Text.Glabrous.Types.Result instance GHC.Show.Show Text.Glabrous.Types.Context instance GHC.Classes.Eq Text.Glabrous.Types.Context instance GHC.Generics.Generic Text.Glabrous.Types.Template instance GHC.Show.Show Text.Glabrous.Types.Template instance GHC.Classes.Eq Text.Glabrous.Types.Template instance GHC.Generics.Generic Text.Glabrous.Types.Token instance GHC.Show.Show Text.Glabrous.Types.Token instance GHC.Classes.Eq Text.Glabrous.Types.Token instance Data.Aeson.Types.ToJSON.ToJSON Text.Glabrous.Types.Context instance Data.Aeson.Types.FromJSON.FromJSON Text.Glabrous.Types.Context instance Data.Serialize.Serialize Text.Glabrous.Types.Template instance Data.Serialize.Serialize Text.Glabrous.Types.Token -- | A minimalistic Mustache-like syntax, truly logic-less, pure -- Text template library -- -- module Text.Glabrous newtype Template Template :: [Token] -> Template [content] :: Template -> [Token] -- | Build a Template from a Text. -- --
--   λ>fromText "Glabrous templates use only the simplest Mustache tag: {{name}}."
--   Right (Template {content = [Literal "Glabrous templates use only the simplest Mustache tag: ",Tag "name",Literal "."]})
--   
fromText :: Text -> Either String Template -- | Get a Template from a file. readTemplateFile :: FilePath -> IO (Either String Template) -- | Get Just a new Template with new tag(s) inside, or -- Nothing. addTag :: Template -> Text -> Text -> Maybe Template -- | Get the list of Tags in the given Template. tagsOf :: Template -> [Token] tagsRename :: [(Text, Text)] -> Template -> Template -- | True if a Template has no more Tag inside and can -- be used as a final Text. isFinal :: Template -> Bool -- | Output the content of the given Template as it is, with its -- Tags, if they exist. toText :: Template -> Text -- | Output the content of the given Template with all its -- Tags removed. toFinalText :: Template -> Text -- | Optimize a Template content after (many) -- partialProcess(') rewriting(s). compress :: Template -> Template -- | Write a Template to a file. writeTemplateFile :: FilePath -> Template -> IO () -- | get Just a new Template by inserting a Template -- into another one by replacing the Tag, or Nothing. -- --
--   λ>insert t0 (Tag "template1") t1
--   
insertTemplate :: Template -> Token -> Template -> Maybe Template -- | get Just a new Template by inserting many -- Templates, if there is at least one tag correspondence, or -- Nothing. -- --
--   λ>insertMany t0 [(Tag "template1",t1),(Tag "template2",t2)]
--   
insertManyTemplates :: Template -> [(Token, Template)] -> Maybe Template newtype Context Context :: HashMap Text Text -> Context [variables] :: Context -> HashMap Text Text -- | Build an empty Context. initContext :: Context -- | Build an unset Context from a list of Tags. -- --
--   λ>fromTagsList ["tag","etc."]
--   Context {variables = fromList [("etc.",""),("tag","")]}
--   
fromTagsList :: [Text] -> Context -- | Build a Context from a list of Tags and replacement -- Texts. -- --
--   λ>fromList [("tag","replacement"), ("etc.","...")]
--   Context {variables = fromList [("etc.","..."),("tag","replacement")]}
--   
fromList :: [(Text, Text)] -> Context -- | Build an unset ad hoc Context from the given Template. fromTemplate :: Template -> Context -- | Populate with variables and/or update variables in the given -- Context. -- --
--   λ>setVariables [("tag","replacement"), ("theme","Haskell")] context
--   Context {variables = fromList [("etc.","..."),("theme","Haskell"),("tag","replacement"),("name","")]}
--   
setVariables :: [(Text, Text)] -> Context -> Context -- | Delete variables from a Context by these names. -- --
--   λ>deleteVariables ["tag"] context
--   Context {variables = fromList [("etc.","..."),("theme","Haskell"),("name","")]}
--   
deleteVariables :: [Text] -> Context -> Context -- | Get the list of the given Context variables. variablesOf :: Context -> [Text] -- | True if the all variables of the given Context are not -- empty. isSet :: Context -> Bool -- | Build Just a (sub)Context made of unset variables of the -- given context, or Nothing. -- --
--   λ>unsetContext context
--   Just (Context {variables = fromList [("name","")]})
--   
unsetContext :: Context -> Maybe Context -- | Join two Contexts if they don't share variables name, or get -- the intersection Context out of them. join :: Context -> Context -> Either Context Context -- | Get a Context from a JSON file. readContextFile :: FilePath -> IO (Maybe Context) -- | Write a Context to a file. -- --
--   {
--       "tag": "replacement",
--       "etc.": "..."
--   }
--   
writeContextFile :: FilePath -> Context -> IO () -- | Based on the given Context, write a JSON Context file -- with all its variables empty. -- --
--   {
--       "tag": "",
--       "etc.": ""
--   }
--   
initContextFile :: FilePath -> Context -> IO () -- | Process, discard Tags which are not in the Context and -- replace them with nothing in the final Text. process :: Template -> Context -> Text -- | Process and replace missing variables in Context with the given -- default replacement Text. processWithDefault :: Text -> Template -> Context -> Text -- | Process a (sub)Context present in the given template, leaving -- untouched, if they exist, other Tags, to obtain a new template. partialProcess :: Template -> Context -> Template data Result Final :: !Text -> Result Partial :: !Template -> !Context -> Result [template] :: Result -> !Template [context] :: Result -> !Context -- | Process a (sub)Context present in the given template, and get -- either a Final Text or a new Template with its -- unset ad hoc Context. -- --
--   λ>partialProcess' template context
--   Partial {template = Template {content = [Literal "Some ",Tag "tags",Literal " are unused in this ",Tag "text",Literal "."]}, context = Context {variables = fromList [("text",""),("tags","")]}}
--   
partialProcess' :: Template -> Context -> Result