ihp-hsx-0.20.0: JSX-like but for Haskell
Copyright(c) digitally induced GmbH 2022
Safe HaskellSafe-Inferred
LanguageHaskell2010

IHP.HSX.Parser

Description

 
Synopsis

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

data Node Source #

Constructors

Node !Text ![Attribute] ![Node] !Bool 
TextNode !Text 
PreEscapedTextNode !Text

Used in script or style bodies

SplicedNode !Exp

Inline haskell expressions like {myVar} or {f "hello"}

Children ![Node] 
CommentNode !Text 

Instances

Instances details
Show Node Source # 
Instance details

Defined in IHP.HSX.Parser

Methods

showsPrec :: Int -> Node -> ShowS #

show :: Node -> String #

showList :: [Node] -> ShowS #

Eq Node Source # 
Instance details

Defined in IHP.HSX.Parser

Methods

(==) :: Node -> Node -> Bool #

(/=) :: Node -> Node -> Bool #

data Attribute Source #

Instances

Instances details
Show Attribute Source # 
Instance details

Defined in IHP.HSX.Parser

Eq Attribute Source # 
Instance details

Defined in IHP.HSX.Parser

data AttributeValue Source #

Instances

Instances details
Show AttributeValue Source # 
Instance details

Defined in IHP.HSX.Parser

Eq AttributeValue Source # 
Instance details

Defined in IHP.HSX.Parser

collapseSpace :: Text -> Text Source #

Replaces multiple space characters with a single one