shakespeare-2.0.13: A toolkit for making compile-time interpolated templates

Safe Haskell | None
Language | Haskell98

Text.Lucius

Contents

- Parsing
  - Mixins
  - Runtime
    - Mixin
- Datatypes
- Type class
- Rendering
- ToCss instances
  - Color
  - Size
- Internal

Synopsis

- lucius :: QuasiQuoter
- luciusFile :: FilePath -> Q Exp
- luciusFileDebug :: FilePath -> Q Exp
- luciusFileReload :: FilePath -> Q Exp
- luciusMixin :: QuasiQuoter
- data Mixin
- luciusRT :: Text -> [(Text, Text)] -> Either String Text
- luciusRT' :: Text -> Either String ([(Text, Text)] -> Either String [TopLevel Resolved])
- luciusRTMinified :: Text -> [(Text, Text)] -> Either String Text
- luciusRTMixin :: Text -> Bool -> [(Text, RTValue)] -> Either String Text
- data RTValue
  - = RTVRaw Text
  - | RTVMixin Mixin
- data Css
- type CssUrl url = (url -> [(Text, Text)] -> Text) -> Css
- class ToCss a where
- renderCss :: Css -> Text
- renderCssUrl :: (url -> [(Text, Text)] -> Text) -> CssUrl url -> Text
- data Color = Color Word8 Word8 Word8
- colorRed :: Color
- colorBlack :: Color
- mkSize :: String -> ExpQ
- data AbsoluteUnit
  - = Centimeter
  - | Inch
  - | Millimeter
  - | Pica
  - | Point
- data AbsoluteSize = AbsoluteSize {
  - absoluteSizeUnit :: AbsoluteUnit
  - absoluteSizeValue :: Rational
  }
- absoluteSize :: AbsoluteUnit -> Rational -> AbsoluteSize
- data EmSize = EmSize Rational
- data ExSize = ExSize Rational
- data PercentageSize = PercentageSize {
  - percentageSizeValue :: Rational
  }
- percentageSize :: Rational -> PercentageSize
- data PixelSize = PixelSize Rational
- parseTopLevels :: Parser [TopLevel Unresolved]
- luciusUsedIdentifiers :: String -> [(Deref, VarType)]

# Parsing

lucius :: QuasiQuoter #

    >>> renderCss ([lucius|foo{bar:baz}|] undefined)
    "foo{bar:baz}"

luciusFile :: FilePath -> Q Exp #

luciusFileDebug :: FilePath -> Q Exp #

luciusFileReload :: FilePath -> Q Exp #

## Mixins

luciusMixin :: QuasiQuoter #

data Mixin #

Instances

Monoid Mixin # |
Methods mempty :: Mixin # mappend :: Mixin -> Mixin -> Mixin # mconcat :: [Mixin] -> Mixin #
Lift Mixin # |
Methods lift :: Mixin -> Q Exp #

## Runtime

luciusRT :: Text -> [(Text, Text)] -> Either String Text #

luciusRT' :: Text -> Either String ([(Text, Text)] -> Either String [TopLevel Resolved]) #

luciusRTMinified :: Text -> [(Text, Text)] -> Either String Text #

Same as `luciusRT`, but output has no added whitespace.

Since 1.0.3

### Mixin

luciusRTMixin #

Arguments

:: Text | template
-> Bool | minify?
-> [(Text, RTValue)] | scope
-> Either String Text |

Runtime Lucius with mixin support.

Since 1.0.6

data RTValue #

Constructors

RTVRaw Text |
RTVMixin Mixin |

# Datatypes

data Css #

type CssUrl url = (url -> [(Text, Text)] -> Text) -> Css #

# Type class

class ToCss a where #

Minimal complete definition

toCss

Methods

toCss :: a -> Builder #

Instances

ToCss Text # |
Methods toCss :: Text -> Builder #
ToCss Text # |
Methods toCss :: Text -> Builder #
ToCss PercentageSize # |
Methods toCss :: PercentageSize -> Builder #
ToCss AbsoluteSize # |
Methods toCss :: AbsoluteSize -> Builder #
ToCss Color # |
Methods toCss :: Color -> Builder #
ToCss EmSize # |
Methods toCss :: EmSize -> Builder #
ToCss ExSize # |
Methods toCss :: ExSize -> Builder #
ToCss PixelSize # |
Methods toCss :: PixelSize -> Builder #
ToCss [Char] # |
Methods toCss :: [Char] -> Builder #

# Rendering

renderCss :: Css -> Text #

renderCssUrl :: (url -> [(Text, Text)] -> Text) -> CssUrl url -> Text #

# ToCss instances

## Color

data Color #

Constructors

Color Word8 Word8 Word8 |

Instances

Show Color # |
Methods showsPrec :: Int -> Color -> ShowS # show :: Color -> String # showList :: [Color] -> ShowS #
ToCss Color # |
Methods toCss :: Color -> Builder #

colorRed :: Color #

colorBlack :: Color #

## Size

mkSize :: String -> ExpQ #

Create a CSS size, e.g. $(mkSize "100px").

data AbsoluteUnit #

Absolute size units.

Constructors

Centimeter |
Inch |
Millimeter |
Pica |
Point |

Instances

Eq AbsoluteUnit # |
Methods (==) :: AbsoluteUnit -> AbsoluteUnit -> Bool # (/=) :: AbsoluteUnit -> AbsoluteUnit -> Bool #
Show AbsoluteUnit # |
Methods showsPrec :: Int -> AbsoluteUnit -> ShowS # show :: AbsoluteUnit -> String # showList :: [AbsoluteUnit] -> ShowS #

data AbsoluteSize #

Not intended for direct use, see `mkSize`.

Constructors

AbsoluteSize |
Fields absoluteSizeUnit :: AbsoluteUnit Units used for text formatting. absoluteSizeValue :: Rational Normalized value in centimeters.

Instances

Eq AbsoluteSize # |
Methods (==) :: AbsoluteSize -> AbsoluteSize -> Bool # (/=) :: AbsoluteSize -> AbsoluteSize -> Bool #
Fractional AbsoluteSize # |
Methods (/) :: AbsoluteSize -> AbsoluteSize -> AbsoluteSize # recip :: AbsoluteSize -> AbsoluteSize # fromRational :: Rational -> AbsoluteSize #
Num AbsoluteSize # |
Methods (+) :: AbsoluteSize -> AbsoluteSize -> AbsoluteSize # (-) :: AbsoluteSize -> AbsoluteSize -> AbsoluteSize # (*) :: AbsoluteSize -> AbsoluteSize -> AbsoluteSize # negate :: AbsoluteSize -> AbsoluteSize # abs :: AbsoluteSize -> AbsoluteSize # signum :: AbsoluteSize -> AbsoluteSize # fromInteger :: Integer -> AbsoluteSize #
Ord AbsoluteSize # |
Methods compare :: AbsoluteSize -> AbsoluteSize -> Ordering # (<) :: AbsoluteSize -> AbsoluteSize -> Bool # (<=) :: AbsoluteSize -> AbsoluteSize -> Bool # (>) :: AbsoluteSize -> AbsoluteSize -> Bool # (>=) :: AbsoluteSize -> AbsoluteSize -> Bool # max :: AbsoluteSize -> AbsoluteSize -> AbsoluteSize # min :: AbsoluteSize -> AbsoluteSize -> AbsoluteSize #
Show AbsoluteSize # |
Methods showsPrec :: Int -> AbsoluteSize -> ShowS # show :: AbsoluteSize -> String # showList :: [AbsoluteSize] -> ShowS #
ToCss AbsoluteSize # |
Methods toCss :: AbsoluteSize -> Builder #

absoluteSize :: AbsoluteUnit -> Rational -> AbsoluteSize #

Constructs `AbsoluteSize`. Not intended for direct use, see `mkSize`.

data EmSize #

Constructors

EmSize Rational |

Instances

Eq EmSize # |
Methods (==) :: EmSize -> EmSize -> Bool # (/=) :: EmSize -> EmSize -> Bool #
Fractional EmSize # |
Methods (/) :: EmSize -> EmSize -> EmSize # recip :: EmSize -> EmSize # fromRational :: Rational -> EmSize #
Num EmSize # |
Methods (+) :: EmSize -> EmSize -> EmSize # (-) :: EmSize -> EmSize -> EmSize # (*) :: EmSize -> EmSize -> EmSize # negate :: EmSize -> EmSize # abs :: EmSize -> EmSize # signum :: EmSize -> EmSize # fromInteger :: Integer -> EmSize #
Ord EmSize # |
Methods compare :: EmSize -> EmSize -> Ordering # (<) :: EmSize -> EmSize -> Bool # (<=) :: EmSize -> EmSize -> Bool # (>) :: EmSize -> EmSize -> Bool # (>=) :: EmSize -> EmSize -> Bool # max :: EmSize -> EmSize -> EmSize # min :: EmSize -> EmSize -> EmSize #
Show EmSize # |
Methods showsPrec :: Int -> EmSize -> ShowS # show :: EmSize -> String # showList :: [EmSize] -> ShowS #
ToCss EmSize # |
Methods toCss :: EmSize -> Builder #

data ExSize #

Constructors

ExSize Rational |

Instances

Eq ExSize # |
Methods (==) :: ExSize -> ExSize -> Bool # (/=) :: ExSize -> ExSize -> Bool #
Fractional ExSize # |
Methods (/) :: ExSize -> ExSize -> ExSize # recip :: ExSize -> ExSize # fromRational :: Rational -> ExSize #
Num ExSize # |
Methods (+) :: ExSize -> ExSize -> ExSize # (-) :: ExSize -> ExSize -> ExSize # (*) :: ExSize -> ExSize -> ExSize # negate :: ExSize -> ExSize # abs :: ExSize -> ExSize # signum :: ExSize -> ExSize # fromInteger :: Integer -> ExSize #
Ord ExSize # |
Methods compare :: ExSize -> ExSize -> Ordering # (<) :: ExSize -> ExSize -> Bool # (<=) :: ExSize -> ExSize -> Bool # (>) :: ExSize -> ExSize -> Bool # (>=) :: ExSize -> ExSize -> Bool # max :: ExSize -> ExSize -> ExSize # min :: ExSize -> ExSize -> ExSize #
Show ExSize # |
Methods showsPrec :: Int -> ExSize -> ShowS # show :: ExSize -> String # showList :: [ExSize] -> ShowS #
ToCss ExSize # |
Methods toCss :: ExSize -> Builder #

data PercentageSize #

Not intended for direct use, see `mkSize`.

Constructors

PercentageSize |
Fields percentageSizeValue :: Rational Normalized value, 1 == 100%.

Instances

Eq PercentageSize # |
Methods (==) :: PercentageSize -> PercentageSize -> Bool # (/=) :: PercentageSize -> PercentageSize -> Bool #
Fractional PercentageSize # |
Methods (/) :: PercentageSize -> PercentageSize -> PercentageSize # recip :: PercentageSize -> PercentageSize # fromRational :: Rational -> PercentageSize #
Num PercentageSize # |
Methods (+) :: PercentageSize -> PercentageSize -> PercentageSize # (-) :: PercentageSize -> PercentageSize -> PercentageSize # (*) :: PercentageSize -> PercentageSize -> PercentageSize # negate :: PercentageSize -> PercentageSize # abs :: PercentageSize -> PercentageSize # signum :: PercentageSize -> PercentageSize # fromInteger :: Integer -> PercentageSize #
Ord PercentageSize # |
Methods compare :: PercentageSize -> PercentageSize -> Ordering # (<) :: PercentageSize -> PercentageSize -> Bool # (<=) :: PercentageSize -> PercentageSize -> Bool # (>) :: PercentageSize -> PercentageSize -> Bool # (>=) :: PercentageSize -> PercentageSize -> Bool # max :: PercentageSize -> PercentageSize -> PercentageSize # min :: PercentageSize -> PercentageSize -> PercentageSize #
Show PercentageSize # |
Methods showsPrec :: Int -> PercentageSize -> ShowS # show :: PercentageSize -> String # showList :: [PercentageSize] -> ShowS #
ToCss PercentageSize # |
Methods toCss :: PercentageSize -> Builder #

percentageSize :: Rational -> PercentageSize #

Constructs `PercentageSize`. Not intended for direct use, see `mkSize`.

data PixelSize #

Constructors

PixelSize Rational |

Instances

Eq PixelSize # |
Methods (==) :: PixelSize -> PixelSize -> Bool # (/=) :: PixelSize -> PixelSize -> Bool #
Fractional PixelSize # |
Methods (/) :: PixelSize -> PixelSize -> PixelSize # recip :: PixelSize -> PixelSize # fromRational :: Rational -> PixelSize #
Num PixelSize # |
Methods (+) :: PixelSize -> PixelSize -> PixelSize # (-) :: PixelSize -> PixelSize -> PixelSize # (*) :: PixelSize -> PixelSize -> PixelSize # negate :: PixelSize -> PixelSize # abs :: PixelSize -> PixelSize # signum :: PixelSize -> PixelSize # fromInteger :: Integer -> PixelSize #
Ord PixelSize # |
Methods compare :: PixelSize -> PixelSize -> Ordering # (<) :: PixelSize -> PixelSize -> Bool # (<=) :: PixelSize -> PixelSize -> Bool # (>) :: PixelSize -> PixelSize -> Bool # (>=) :: PixelSize -> PixelSize -> Bool # max :: PixelSize -> PixelSize -> PixelSize # min :: PixelSize -> PixelSize -> PixelSize #
Show PixelSize # |
Methods showsPrec :: Int -> PixelSize -> ShowS # show :: PixelSize -> String # showList :: [PixelSize] -> ShowS #
ToCss PixelSize # |
Methods toCss :: PixelSize -> Builder #

# Internal

parseTopLevels :: Parser [TopLevel Unresolved] #

luciusUsedIdentifiers :: String -> [(Deref, VarType)] #

Determine which identifiers are used by the given template, useful for creating systems like yesod devel.