slab-0.0.2.0: A programmable markup language to generate HTML
Safe HaskellSafe-Inferred
LanguageHaskell2010

Slab.Syntax

Description

Slab.Syntax provides data types to represent the syntax used by the Slab language. It also provides small helpers functions to operate on the syntax.

Synopsis

Documentation

data Block Source #

Constructors

BlockDoctype

Only doctype html for now.

BlockElem Elem TrailingSym [Attr] [Block] 
BlockText TextSyntax [Inline] 
BlockInclude (Maybe Text) FilePath (Maybe [Block])

Nothing when the template is parsed, then Just nodes after preprocessing (i.e. actually running the include statement). The filter name follows the same behavior as BlockFilter.

BlockFragmentDef Text [Text] [Block]

This doesn't exist in Pug. This is like a mixin than receive block arguments. Or like a parent template that can be extended by a child template.

BlockFragmentCall Text TrailingSym [Attr] [Expr] [Block] 
BlockFor Text (Maybe Text) Expr [Block] 
BlockComment CommentType Text 
BlockFilter Text Text 
BlockRawElem Text [Block] 
BlockDefault Text [Block]

default defines an optional formal parameter with a default content. Its content is used when the argument is not given.

BlockImport FilePath (Maybe [Block]) [Block]

Similar to an anonymous fragment call, where the fragment body is the content of the referenced file.

BlockRun Text (Maybe [Block]) 
BlockReadJson Text FilePath (Maybe Value)

Allow to assign the content of a JSON file to a variable. The syntax is specific to how Struct has a require function in scope.

BlockAssignVar Text Expr 
BlockIf Expr [Block] [Block] 
BlockList [Block] 
BlockCode Expr 

Instances

Instances details
Show Block Source # 
Instance details

Defined in Slab.Syntax

Methods

showsPrec :: Int -> Block -> ShowS #

show :: Block -> String #

showList :: [Block] -> ShowS #

Eq Block Source # 
Instance details

Defined in Slab.Syntax

Methods

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

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

pasteBlocks :: Block -> Block -> Block Source #

Takes two blocks and returns a BlockList containing both, but peel the outer list of a and b if they are themselves BlockList.

setAttrs :: [Attr] -> [Block] -> [Block] Source #

Set attrs on a the first block, if it is a BlockElem.

setContent :: [Block] -> Block -> Block Source #

Set the content on a block, if it is a BlockElem.

data CommentType Source #

A "passthrough" comment will be included in the generated HTML.

Instances

Instances details
Show CommentType Source # 
Instance details

Defined in Slab.Syntax

Eq CommentType Source # 
Instance details

Defined in Slab.Syntax

data Elem Source #

Constructors

Html 
Body 
Div 
Span 
Br 
Hr 
H1 
H2 
H3 
H4 
H5 
H6 
Header 
Head 
Meta 
Main 
Link 
A 
P 
Ul 
Li 
Title 
Table 
Thead 
Tbody 
Tr 
Td 
Dl 
Dt 
Dd 
Footer 
Figure 
Form 
Label 
Blockquote 
Button 
Figcaption 
Audio 
Script 
Style 
Small 
Source 
Pre 
Code 
Img 
IFrame 
Input 
I 
Svg 
Textarea 
Canvas 
Elem Text

Arbitrary element name, using the el keyword.

Instances

Instances details
Show Elem Source # 
Instance details

Defined in Slab.Syntax

Methods

showsPrec :: Int -> Elem -> ShowS #

show :: Elem -> String #

showList :: [Elem] -> ShowS #

Eq Elem Source # 
Instance details

Defined in Slab.Syntax

Methods

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

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

data TrailingSym Source #

Constructors

HasDot 
HasEqual 
NoSym 

Instances

Instances details
Show TrailingSym Source # 
Instance details

Defined in Slab.Syntax

Eq TrailingSym Source # 
Instance details

Defined in Slab.Syntax

data Attr Source #

Constructors

Id Text 
Class Text 
Attr Text (Maybe Expr) 

Instances

Instances details
Show Attr Source # 
Instance details

Defined in Slab.Syntax

Methods

showsPrec :: Int -> Attr -> ShowS #

show :: Attr -> String #

showList :: [Attr] -> ShowS #

Eq Attr Source # 
Instance details

Defined in Slab.Syntax

Methods

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

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

data TextSyntax Source #

Constructors

Normal

The text follows an element on the same line.

Pipe

The text follows a pipe character. Multiple lines each introduced by a pipe symbol are grouped as a single BlockText node.

Dot

The text is part of a text block following a trailing dot.

Include

The text is the content of an include statement without a .slab extension.

RunOutput

The text is the output of command.

Instances

Instances details
Show TextSyntax Source # 
Instance details

Defined in Slab.Syntax

Eq TextSyntax Source # 
Instance details

Defined in Slab.Syntax

data Expr Source #

Simple expression language.

Instances

Instances details
Show Expr Source # 
Instance details

Defined in Slab.Syntax

Methods

showsPrec :: Int -> Expr -> ShowS #

show :: Expr -> String #

showList :: [Expr] -> ShowS #

Eq Expr Source # 
Instance details

Defined in Slab.Syntax

Methods

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

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

data Inline Source #

A representation of a Text template is a list of Inline, supporting efficient rendering. Use parse to create a template from a text containing placeholders. Lit is a literal Text value. Place is a placeholder created with #{...}.

Constructors

Lit !Text 
Place !Expr 

Instances

Instances details
Show Inline Source # 
Instance details

Defined in Slab.Syntax

Eq Inline Source # 
Instance details

Defined in Slab.Syntax

Methods

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

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

data Env Source #

Constructors

Env 

Fields

Instances

Instances details
Show Env Source # 
Instance details

Defined in Slab.Syntax

Methods

showsPrec :: Int -> Env -> ShowS #

show :: Env -> String #

showList :: [Env] -> ShowS #

Eq Env Source # 
Instance details

Defined in Slab.Syntax

Methods

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

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

extractFragments :: [Block] -> [BlockFragment] Source #

findFragment :: Text -> [BlockFragment] -> Maybe [Block] Source #

groupAttrs :: [Attr] -> [Attr] Source #

Group multiple classes or IDs in a single class or ID, and transform the other attributes in SingleQuoteStrings.