-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Small template engine -- -- Haskell implementation of a subset of the PHP-Smarty template language @package HSmarty @version 0.2.0.3 module Text.HSmarty.Parser.Util eolP :: Parser Text boolP :: Parser Bool stringP :: Parser Text identP :: (Char -> Bool) -> (Char -> Bool) -> Parser Text stripSpace :: Parser c -> Parser c space_ :: Parser () optSpace_ :: Parser () between :: Parser a -> Parser b -> Parser c -> Parser c skipWhile1 :: (Char -> Bool) -> Parser () quotedString :: Char -> Parser Text escapeSeq :: Parser Char unicodeSeq :: Parser Char decodeHexUnsafe :: String -> Integer hexDigitUpper :: Parser Char hexDigit :: Parser Char braced :: Parser l -> Parser r -> Parser a -> Parser a listLike :: Parser l -> Parser r -> Parser s -> Parser a -> Parser [a] tupleP :: Parser p -> Parser [p] module Text.HSmarty.Types data Smarty Smarty :: FilePath -> [SmartyStmt] -> Smarty s_name :: Smarty -> FilePath s_template :: Smarty -> [SmartyStmt] type PrintDirective = Text data SmartyStmt SmartyText :: Text -> SmartyStmt SmartyComment :: Text -> SmartyStmt SmartyIf :: If -> SmartyStmt SmartyForeach :: Foreach -> SmartyStmt SmartyPrint :: Expr -> [PrintDirective] -> SmartyStmt data Expr ExprVar :: Variable -> Expr ExprLit :: Value -> Expr ExprFun :: FunctionCall -> Expr ExprBin :: BinOp -> Expr data Variable Variable :: Text -> [Text] -> Maybe Expr -> Maybe Text -> Variable v_name :: Variable -> Text v_path :: Variable -> [Text] v_index :: Variable -> Maybe Expr v_prop :: Variable -> Maybe Text data FunctionCall FunctionCall :: Text -> [(Text, Expr)] -> FunctionCall f_name :: FunctionCall -> Text f_args :: FunctionCall -> [(Text, Expr)] data BinOp BinEq :: Expr -> Expr -> BinOp BinNot :: Expr -> BinOp BinAnd :: Expr -> Expr -> BinOp BinOr :: Expr -> Expr -> BinOp BinLarger :: Expr -> Expr -> BinOp BinSmaller :: Expr -> Expr -> BinOp BinLargerEq :: Expr -> Expr -> BinOp BinSmallerEq :: Expr -> Expr -> BinOp BinPlus :: Expr -> Expr -> BinOp BinMinus :: Expr -> Expr -> BinOp BinMul :: Expr -> Expr -> BinOp BinDiv :: Expr -> Expr -> BinOp data If If :: [(Expr, [SmartyStmt])] -> Maybe [SmartyStmt] -> If if_cases :: If -> [(Expr, [SmartyStmt])] if_else :: If -> Maybe [SmartyStmt] data Foreach Foreach :: Expr -> Maybe Text -> Text -> [SmartyStmt] -> Maybe [SmartyStmt] -> Foreach f_source :: Foreach -> Expr f_key :: Foreach -> Maybe Text f_item :: Foreach -> Text f_body :: Foreach -> [SmartyStmt] f_else :: Foreach -> Maybe [SmartyStmt] instance Eq BinOp instance Show BinOp instance Eq Expr instance Show Expr instance Eq FunctionCall instance Show FunctionCall instance Eq Variable instance Show Variable instance Eq Foreach instance Show Foreach instance Eq SmartyStmt instance Show SmartyStmt instance Eq If instance Show If instance Eq Smarty instance Show Smarty module Text.HSmarty.Parser.Smarty parseSmarty :: Monad m => FilePath -> Text -> m Smarty pRoot :: Parser [SmartyStmt] pStmt :: Parser SmartyStmt pPrintDirective :: Parser PrintDirective pExpr :: Parser Expr pValExpr :: Parser Expr pLit :: Parser Value pVar :: Parser Variable pName :: Parser Text pLiteral :: Parser Text pComment :: Parser Text pFunCall :: Parser FunctionCall pOpen :: Text -> Parser Text pOpenExpr :: Text -> Parser Expr pClose :: Text -> Parser Text pIf :: Parser If pForeach :: Parser Foreach opTable :: [[Operator Text Expr]] module Text.HSmarty -- | An template param, construct using mkParam data TemplateParam -- | Maps template variables to template params type ParamMap = HashMap Text TemplateParam -- | Pack a value as a template param mkParam :: ToJSON a => a -> TemplateParam data SmartyCtx newtype SmartyError SmartyError :: Text -> SmartyError unSmartyError :: SmartyError -> Text -- | Parse and compile a template prepareTemplate :: FilePath -> IO SmartyCtx -- | Fill a template with values and print it as Text applyTemplate :: SmartyCtx -> ParamMap -> IO (Either SmartyError Text) -- | Render a template using the specified ParamMap. Results in either an -- error-message or the rendered template. DO NOT USE IN Production. Use -- prepareTemplate and applyTemplate instead. renderTemplate :: FilePath -> ParamMap -> IO (Either SmartyError Text)