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

Safe Haskell | None
Language | Haskell2010

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

Instances details

Semigroup Mixin Source # |
Instance details Defined in Text.Internal.Css Methods (<>) :: Mixin -> Mixin -> Mixin sconcat :: NonEmpty Mixin -> Mixin stimes :: Integral b => b -> Mixin -> Mixin
Monoid Mixin Source # |
Instance details Defined in Text.Internal.Css Methods mempty :: Mixin mappend :: Mixin -> Mixin -> Mixin mconcat :: [Mixin] -> Mixin
Lift Mixin Source # |
Instance details Defined in Text.Internal.Css 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 #

Methods

toCss :: a -> Builder Source #

#### Instances

Instances details

ToCss Text Source # |
Instance details Defined in Text.Internal.Css Methods toCss :: Text -> Builder Source #
ToCss Text Source # |
Instance details Defined in Text.Internal.Css Methods toCss :: Text -> Builder Source #
ToCss PercentageSize Source # |
Instance details Defined in Text.Internal.CssCommon Methods toCss :: PercentageSize -> Builder Source #
ToCss AbsoluteSize Source # |
Instance details Defined in Text.Internal.CssCommon Methods toCss :: AbsoluteSize -> Builder Source #
ToCss Color Source # |
Instance details Defined in Text.Internal.CssCommon Methods toCss :: Color -> Builder Source #
ToCss EmSize Source # |
Instance details Defined in Text.Internal.CssCommon Methods toCss :: EmSize -> Builder Source #
ToCss ExSize Source # |
Instance details Defined in Text.Internal.CssCommon Methods toCss :: ExSize -> Builder Source #
ToCss PixelSize Source # |
Instance details Defined in Text.Internal.CssCommon Methods toCss :: PixelSize -> Builder Source #
ToCss [Char] Source # |
Instance details Defined in Text.Internal.Css 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

Instances details

Show Color Source # |
Instance details Defined in Text.Internal.CssCommon Methods showsPrec :: Int -> Color -> ShowS show :: Color -> String showList :: [Color] -> ShowS
ToCss Color Source # |
Instance details Defined in Text.Internal.CssCommon 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

Instances details

Eq AbsoluteUnit Source # |
Instance details Defined in Text.Internal.CssCommon Methods (==) :: AbsoluteUnit -> AbsoluteUnit -> Bool (/=) :: AbsoluteUnit -> AbsoluteUnit -> Bool
Show AbsoluteUnit Source # |
Instance details Defined in Text.Internal.CssCommon 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

Instances details

Eq AbsoluteSize Source # |
Instance details Defined in Text.Internal.CssCommon Methods (==) :: AbsoluteSize -> AbsoluteSize -> Bool (/=) :: AbsoluteSize -> AbsoluteSize -> Bool
Fractional AbsoluteSize Source # |
Instance details Defined in Text.Internal.CssCommon Methods (/) :: AbsoluteSize -> AbsoluteSize -> AbsoluteSize recip :: AbsoluteSize -> AbsoluteSize fromRational :: Rational -> AbsoluteSize
Num AbsoluteSize Source # |
Instance details Defined in Text.Internal.CssCommon 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 # |
Instance details Defined in Text.Internal.CssCommon 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 # |
Instance details Defined in Text.Internal.CssCommon Methods showsPrec :: Int -> AbsoluteSize -> ShowS show :: AbsoluteSize -> String showList :: [AbsoluteSize] -> ShowS
ToCss AbsoluteSize Source # |
Instance details Defined in Text.Internal.CssCommon 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

Instances details

Eq EmSize Source # |
Instance details Defined in Text.Internal.CssCommon Methods (==) :: EmSize -> EmSize -> Bool (/=) :: EmSize -> EmSize -> Bool
Fractional EmSize Source # |
Instance details Defined in Text.Internal.CssCommon Methods (/) :: EmSize -> EmSize -> EmSize recip :: EmSize -> EmSize fromRational :: Rational -> EmSize
Num EmSize Source # |
Instance details Defined in Text.Internal.CssCommon 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 # |
Instance details Defined in Text.Internal.CssCommon 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 # |
Instance details Defined in Text.Internal.CssCommon Methods showsPrec :: Int -> EmSize -> ShowS show :: EmSize -> String showList :: [EmSize] -> ShowS
ToCss EmSize Source # |
Instance details Defined in Text.Internal.CssCommon Methods toCss :: EmSize -> Builder Source #

data ExSize Source #

Constructors

ExSize Rational |

#### Instances

Instances details

Eq ExSize Source # |
Instance details Defined in Text.Internal.CssCommon Methods (==) :: ExSize -> ExSize -> Bool (/=) :: ExSize -> ExSize -> Bool
Fractional ExSize Source # |
Instance details Defined in Text.Internal.CssCommon Methods (/) :: ExSize -> ExSize -> ExSize recip :: ExSize -> ExSize fromRational :: Rational -> ExSize
Num ExSize Source # |
Instance details Defined in Text.Internal.CssCommon 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 # |
Instance details Defined in Text.Internal.CssCommon 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 # |
Instance details Defined in Text.Internal.CssCommon Methods showsPrec :: Int -> ExSize -> ShowS show :: ExSize -> String showList :: [ExSize] -> ShowS
ToCss ExSize Source # |
Instance details Defined in Text.Internal.CssCommon 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

Instances details

Eq PercentageSize Source # |
Instance details Defined in Text.Internal.CssCommon Methods (==) :: PercentageSize -> PercentageSize -> Bool (/=) :: PercentageSize -> PercentageSize -> Bool
Fractional PercentageSize Source # |
Instance details Defined in Text.Internal.CssCommon Methods (/) :: PercentageSize -> PercentageSize -> PercentageSize recip :: PercentageSize -> PercentageSize fromRational :: Rational -> PercentageSize
Num PercentageSize Source # |
Instance details Defined in Text.Internal.CssCommon 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 # |

Instance details

Defined in Text.Internal.CssCommon

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 # |
Instance details Defined in Text.Internal.CssCommon Methods showsPrec :: Int -> PercentageSize -> ShowS show :: PercentageSize -> String showList :: [PercentageSize] -> ShowS
ToCss PercentageSize Source # |
Instance details Defined in Text.Internal.CssCommon 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

Instances details

Eq PixelSize Source # |
Instance details Defined in Text.Internal.CssCommon Methods (==) :: PixelSize -> PixelSize -> Bool (/=) :: PixelSize -> PixelSize -> Bool
Fractional PixelSize Source # |
Instance details Defined in Text.Internal.CssCommon Methods (/) :: PixelSize -> PixelSize -> PixelSize recip :: PixelSize -> PixelSize fromRational :: Rational -> PixelSize
Num PixelSize Source # |
Instance details Defined in Text.Internal.CssCommon 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 # |
Instance details Defined in Text.Internal.CssCommon 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 # |
Instance details Defined in Text.Internal.CssCommon Methods showsPrec :: Int -> PixelSize -> ShowS show :: PixelSize -> String showList :: [PixelSize] -> ShowS
ToCss PixelSize Source # |
Instance details Defined in Text.Internal.CssCommon 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.