shakespeare-2.0.7: 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
  - toCss :: a -> Builder
- 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 |
Lift Mixin Source |

## 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

Methods

toCss :: a -> Builder Source

Instances

ToCss Text Source |
ToCss Text Source |
ToCss PercentageSize Source |
ToCss AbsoluteSize Source |
ToCss Color Source |
ToCss EmSize Source |
ToCss ExSize Source |
ToCss PixelSize Source |
ToCss [Char] 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 |
ToCss Color 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 |
Show AbsoluteUnit Source |

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 |
Fractional AbsoluteSize Source |
Num AbsoluteSize Source |
Ord AbsoluteSize Source |
Show AbsoluteSize Source |
ToCss AbsoluteSize 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 |
Fractional EmSize Source |
Num EmSize Source |
Ord EmSize Source |
Show EmSize Source |
ToCss EmSize Source |

data ExSize Source

Constructors

ExSize Rational |

Instances

Eq ExSize Source |
Fractional ExSize Source |
Num ExSize Source |
Ord ExSize Source |
Show ExSize Source |
ToCss ExSize Source |

data PercentageSize Source

Not intended for direct use, see `mkSize`.

Constructors

PercentageSize |

Fields

percentageSizeValue :: Rational

  Normalized value, 1 == 100%.

Instances

Eq PercentageSize Source |
Fractional PercentageSize Source |
Num PercentageSize Source |
Ord PercentageSize Source |
Show PercentageSize Source |
ToCss PercentageSize Source |

percentageSize :: Rational -> PercentageSize Source

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

data PixelSize Source

Constructors

PixelSize Rational |

Instances

Eq PixelSize Source |
Fractional PixelSize Source |
Num PixelSize Source |
Ord PixelSize Source |
Show PixelSize Source |
ToCss PixelSize 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.