shakespeare-2.0.14.1: 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 Source #

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

luciusFile :: FilePath -> Q Exp Source #

luciusFileDebug :: FilePath -> Q Exp Source #

luciusFileReload :: FilePath -> Q Exp Source #

## Mixins

luciusMixin :: QuasiQuoter Source #

data Mixin Source #

Instances

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

## Runtime

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

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

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

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

Since 1.0.3

### Mixin

luciusRTMixin Source #

Arguments

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

Runtime Lucius with mixin support.

Since 1.0.6

data RTValue Source #

Constructors

RTVRaw Text |
RTVMixin Mixin |

# Datatypes

data Css Source #

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

# Type class

class ToCss a where Source #

Minimal complete definition

toCss

Methods

toCss :: a -> Builder Source #

Instances

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

# Rendering

renderCss :: Css -> Text Source #

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

# ToCss instances

## Color

data Color Source #

Constructors

Color Word8 Word8 Word8 |

Instances

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

colorRed :: Color Source #

colorBlack :: Color Source #

## Size

mkSize :: String -> ExpQ Source #

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

data AbsoluteUnit Source #

Absolute size units.

Constructors

Centimeter |
Inch |
Millimeter |
Pica |
Point |

Instances

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

data AbsoluteSize Source #

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 Source # |
Methods (==) :: AbsoluteSize -> AbsoluteSize -> Bool # (/=) :: AbsoluteSize -> AbsoluteSize -> Bool #
Fractional AbsoluteSize Source # |
Methods (/) :: AbsoluteSize -> AbsoluteSize -> AbsoluteSize # recip :: AbsoluteSize -> AbsoluteSize # fromRational :: Rational -> AbsoluteSize #
Num AbsoluteSize Source # |
Methods (+) :: AbsoluteSize -> AbsoluteSize -> AbsoluteSize # (-) :: AbsoluteSize -> AbsoluteSize -> AbsoluteSize # (*) :: AbsoluteSize -> AbsoluteSize -> AbsoluteSize # negate :: AbsoluteSize -> AbsoluteSize # abs :: AbsoluteSize -> AbsoluteSize # signum :: AbsoluteSize -> AbsoluteSize # fromInteger :: Integer -> AbsoluteSize #
Ord AbsoluteSize Source # |
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 Source # |
Methods showsPrec :: Int -> AbsoluteSize -> ShowS # show :: AbsoluteSize -> String # showList :: [AbsoluteSize] -> ShowS #
ToCss AbsoluteSize Source # |
Methods toCss :: AbsoluteSize -> Builder Source #

absoluteSize :: AbsoluteUnit -> Rational -> AbsoluteSize Source #

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

data EmSize Source #

Constructors

EmSize Rational |

Instances

Eq EmSize Source # |
Methods (==) :: EmSize -> EmSize -> Bool # (/=) :: EmSize -> EmSize -> Bool #
Fractional EmSize Source # |
Methods (/) :: EmSize -> EmSize -> EmSize # recip :: EmSize -> EmSize # fromRational :: Rational -> EmSize #
Num EmSize Source # |
Methods (+) :: EmSize -> EmSize -> EmSize # (-) :: EmSize -> EmSize -> EmSize # (*) :: EmSize -> EmSize -> EmSize # negate :: EmSize -> EmSize # abs :: EmSize -> EmSize # signum :: EmSize -> EmSize # fromInteger :: Integer -> EmSize #
Ord EmSize Source # |
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 Source # |
Methods showsPrec :: Int -> EmSize -> ShowS # show :: EmSize -> String # showList :: [EmSize] -> ShowS #
ToCss EmSize Source # |
Methods toCss :: EmSize -> Builder Source #

data ExSize Source #

Constructors

ExSize Rational |

Instances

Eq ExSize Source # |
Methods (==) :: ExSize -> ExSize -> Bool # (/=) :: ExSize -> ExSize -> Bool #
Fractional ExSize Source # |
Methods (/) :: ExSize -> ExSize -> ExSize # recip :: ExSize -> ExSize # fromRational :: Rational -> ExSize #
Num ExSize Source # |
Methods (+) :: ExSize -> ExSize -> ExSize # (-) :: ExSize -> ExSize -> ExSize # (*) :: ExSize -> ExSize -> ExSize # negate :: ExSize -> ExSize # abs :: ExSize -> ExSize # signum :: ExSize -> ExSize # fromInteger :: Integer -> ExSize #
Ord ExSize Source # |
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 Source # |
Methods showsPrec :: Int -> ExSize -> ShowS # show :: ExSize -> String # showList :: [ExSize] -> ShowS #
ToCss ExSize Source # |
Methods toCss :: ExSize -> Builder Source #

data PercentageSize Source #

Not intended for direct use, see `mkSize`.

Constructors

PercentageSize |

Fields

- percentageSizeValue :: Rational

  Normalized value, 1 == 100%.

Instances

Eq PercentageSize Source # |
Methods (==) :: PercentageSize -> PercentageSize -> Bool # (/=) :: PercentageSize -> PercentageSize -> Bool #
Fractional PercentageSize Source # |
Methods (/) :: PercentageSize -> PercentageSize -> PercentageSize # recip :: PercentageSize -> PercentageSize # fromRational :: Rational -> PercentageSize #
Num PercentageSize Source # |
Methods (+) :: PercentageSize -> PercentageSize -> PercentageSize # (-) :: PercentageSize -> PercentageSize -> PercentageSize # (*) :: PercentageSize -> PercentageSize -> PercentageSize # negate :: PercentageSize -> PercentageSize # abs :: PercentageSize -> PercentageSize # signum :: PercentageSize -> PercentageSize # fromInteger :: Integer -> PercentageSize #
Ord PercentageSize Source # |
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 Source # |
Methods showsPrec :: Int -> PercentageSize -> ShowS # show :: PercentageSize -> String # showList :: [PercentageSize] -> ShowS #
ToCss PercentageSize Source # |
Methods toCss :: PercentageSize -> Builder Source #

percentageSize :: Rational -> PercentageSize Source #

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

data PixelSize Source #

Constructors

PixelSize Rational |

Instances

Eq PixelSize Source # |
Methods (==) :: PixelSize -> PixelSize -> Bool # (/=) :: PixelSize -> PixelSize -> Bool #
Fractional PixelSize Source # |
Methods (/) :: PixelSize -> PixelSize -> PixelSize # recip :: PixelSize -> PixelSize # fromRational :: Rational -> PixelSize #
Num PixelSize Source # |
Methods (+) :: PixelSize -> PixelSize -> PixelSize # (-) :: PixelSize -> PixelSize -> PixelSize # (*) :: PixelSize -> PixelSize -> PixelSize # negate :: PixelSize -> PixelSize # abs :: PixelSize -> PixelSize # signum :: PixelSize -> PixelSize # fromInteger :: Integer -> PixelSize #
Ord PixelSize Source # |
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 Source # |
Methods showsPrec :: Int -> PixelSize -> ShowS # show :: PixelSize -> String # showList :: [PixelSize] -> ShowS #
ToCss PixelSize Source # |
Methods toCss :: PixelSize -> Builder Source #

# Internal

parseTopLevels :: Parser [TopLevel Unresolved] Source #

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

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