module Text.Ginger.AST
where
import Data.Text (Text)
import qualified Data.Text as Text
import Text.Ginger.Html
import Data.Scientific (Scientific)
import Data.HashMap.Strict (HashMap)
import qualified Data.HashMap.Strict as HashMap
type VarName = Text
data Template
= Template
{ templateBody :: Statement
, templateBlocks :: HashMap VarName Block
, templateParent :: Maybe Template
}
deriving (Show)
data Macro
= Macro { macroArgs :: [VarName], macroBody :: Statement }
deriving (Show)
data Block
= Block { blockBody :: Statement }
deriving (Show)
data Statement
= MultiS [Statement]
| ScopedS Statement
| LiteralS Html
| InterpolationS Expression
| IfS Expression Statement Statement
| ForS (Maybe VarName) VarName Expression Statement
| SetVarS VarName Expression
| DefMacroS VarName Macro
| BlockRefS VarName
| PreprocessedIncludeS Template
| NullS
deriving (Show)
data Expression
= StringLiteralE Text
| NumberLiteralE Scientific
| BoolLiteralE Bool
| NullLiteralE
| VarE VarName
| ListE [Expression]
| ObjectE [(Expression, Expression)]
| MemberLookupE Expression Expression
| CallE Expression [(Maybe Text, Expression)]
deriving (Show)