Copyright | (c) digitally induced GmbH 2022 |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- parseHsx :: SourcePos -> Text -> Either (ParseErrorBundle Text Void) Node
- data Node
- = Node !Text ![Attribute] ![Node] !Bool
- | TextNode !Text
- | PreEscapedTextNode !Text
- | SplicedNode !Exp
- | Children ![Node]
- | CommentNode !Text
- data Attribute
- data AttributeValue
- = TextValue !Text
- | ExpressionValue !Exp
- collapseSpace :: Text -> Text
Documentation
parseHsx :: SourcePos -> Text -> Either (ParseErrorBundle Text Void) Node Source #
Parses a HSX text and returns a Node
Example:
let filePath = "my-template" let line = 0 let col = 0 let position = Megaparsec.SourcePos filePath (Megaparsec.mkPos line) (Megaparsec.mkPos col) let hsxText = "<strong>Hello</strong>" let (Right node) = parseHsx position hsxText
Node !Text ![Attribute] ![Node] !Bool | |
TextNode !Text | |
PreEscapedTextNode !Text | Used in |
SplicedNode !Exp | Inline haskell expressions like |
Children ![Node] | |
CommentNode !Text |
data AttributeValue Source #
Instances
Eq AttributeValue Source # | |
Defined in IHP.HSX.Parser (==) :: AttributeValue -> AttributeValue -> Bool # (/=) :: AttributeValue -> AttributeValue -> Bool # | |
Show AttributeValue Source # | |
Defined in IHP.HSX.Parser showsPrec :: Int -> AttributeValue -> ShowS # show :: AttributeValue -> String # showList :: [AttributeValue] -> ShowS # |
collapseSpace :: Text -> Text Source #
Replaces multiple space characters with a single one