Copyright | (c) digitally induced GmbH 2022 |
---|---|
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Synopsis
- parseHsx :: SourcePos -> [Extension] -> Text -> Either (ParseErrorBundle Text Void) Node
- data Node
- = Node !Text ![Attribute] ![Node] !Bool
- | TextNode !Text
- | PreEscapedTextNode !Text
- | SplicedNode !Exp
- | Children ![Node]
- | CommentNode !Text
- | NoRenderCommentNode
- data Attribute
- data AttributeValue
- = TextValue !Text
- | ExpressionValue !Exp
- collapseSpace :: Text -> Text
Documentation
parseHsx :: SourcePos -> [Extension] -> 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 | A Comment that is rendered in the final HTML |
NoRenderCommentNode | A comment that is not rendered in the final HTML |
data AttributeValue Source #
Instances
Show AttributeValue Source # | |
Defined in IHP.HSX.Parser showsPrec :: Int -> AttributeValue -> ShowS # show :: AttributeValue -> String # showList :: [AttributeValue] -> ShowS # | |
Eq AttributeValue Source # | |
Defined in IHP.HSX.Parser (==) :: AttributeValue -> AttributeValue -> Bool # (/=) :: AttributeValue -> AttributeValue -> Bool # |
collapseSpace :: Text -> Text Source #
Replaces multiple space characters with a single one