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

Safe Haskell | None
Language | Haskell2010

Text.Julius

Contents

- Functions
  - Template-Reading Functions
- Datatypes
- Typeclass for interpolated variables
  - Rendering Functions
  - internal, used by `Coffee`
  - internal

Description

A Shakespearean module for Javascript templates, introducing type-safe, compile-time variable and url interpolation.--

You might consider trying `Typescript` or `Coffee` which compile down to Javascript.

Further reading: http://www.yesodweb.com/book/shakespearean-templates

Synopsis

- js :: QuasiQuoter
- julius :: QuasiQuoter
- juliusFile :: FilePath -> Q Exp
- jsFile :: FilePath -> Q Exp
- juliusFileDebug :: FilePath -> Q Exp
- jsFileDebug :: FilePath -> Q Exp
- juliusFileReload :: FilePath -> Q Exp
- jsFileReload :: FilePath -> Q Exp
- type JavascriptUrl url = (url -> [(Text, Text)] -> Text) -> Javascript
- newtype Javascript = Javascript {
  - unJavascript :: Builder
  }
- newtype RawJavascript = RawJavascript Builder
- class ToJavascript a where
  - toJavascript :: a -> Javascript
- class RawJS a where
  - rawJS :: a -> RawJavascript
- renderJavascript :: Javascript -> Text
- renderJavascriptUrl :: (url -> [(Text, Text)] -> Text) -> JavascriptUrl url -> Text
- javascriptSettings :: Q ShakespeareSettings
- juliusUsedIdentifiers :: String -> [(Deref, VarType)]
- asJavascriptUrl :: JavascriptUrl url -> JavascriptUrl url

# Functions

## Template-Reading Functions

These QuasiQuoter and Template Haskell methods return values of type ``JavascriptUrl` url`. See the Yesod book for details.

js :: QuasiQuoter Source #

julius :: QuasiQuoter Source #

juliusFile :: FilePath -> Q Exp Source #

jsFile :: FilePath -> Q Exp Source #

juliusFileDebug :: FilePath -> Q Exp Source #

Deprecated: Please use juliusFileReload instead.

jsFileDebug :: FilePath -> Q Exp Source #

Deprecated: Please use jsFileReload instead.

juliusFileReload :: FilePath -> Q Exp Source #

jsFileReload :: FilePath -> Q Exp Source #

# Datatypes

type JavascriptUrl url = (url -> [(Text, Text)] -> Text) -> Javascript Source #

Return type of template-reading functions.

newtype Javascript Source #

Newtype wrapper of `Builder`.

Constructors

Javascript |

Fields

- unJavascript :: Builder

#### Instances

Instances details

Semigroup Javascript Source # |
Instance details Defined in Text.Julius Methods (<>) :: Javascript -> Javascript -> Javascript sconcat :: NonEmpty Javascript -> Javascript stimes :: Integral b => b -> Javascript -> Javascript
Monoid Javascript Source # |
Instance details Defined in Text.Julius Methods mempty :: Javascript mappend :: Javascript -> Javascript -> Javascript mconcat :: [Javascript] -> Javascript

newtype RawJavascript Source #

Constructors

RawJavascript Builder |

#### Instances

Instances details

ToJavascript RawJavascript Source # |
Instance details Defined in Text.Julius Methods toJavascript :: RawJavascript -> Javascript Source #

# Typeclass for interpolated variables

class ToJavascript a where Source #

A typeclass for types that can be interpolated in CoffeeScript templates.

Methods

toJavascript :: a -> Javascript Source #

#### Instances

Instances details

ToJavascript Bool Source # |
Instance details Defined in Text.Julius Methods toJavascript :: Bool -> Javascript Source #
ToJavascript String Source # |
Instance details Defined in Text.Julius Methods toJavascript :: String -> Javascript Source #
ToJavascript Text Source # |
Instance details Defined in Text.Julius Methods toJavascript :: Text -> Javascript Source #
ToJavascript Value Source # |
Instance details Defined in Text.Julius Methods toJavascript :: Value -> Javascript Source #
ToJavascript Text Source # |
Instance details Defined in Text.Julius Methods toJavascript :: Text -> Javascript Source #
ToJavascript RawJavascript Source # |
Instance details Defined in Text.Julius Methods toJavascript :: RawJavascript -> Javascript Source #

class RawJS a where Source #

Methods

rawJS :: a -> RawJavascript Source #

#### Instances

Instances details

RawJS Bool Source # |
Instance details Defined in Text.Julius Methods rawJS :: Bool -> RawJavascript Source #
RawJS Builder Source # |
Instance details Defined in Text.Julius Methods rawJS :: Builder -> RawJavascript Source #
RawJS Text Source # |
Instance details Defined in Text.Julius Methods rawJS :: Text -> RawJavascript Source #
RawJS Text Source # |
Instance details Defined in Text.Julius Methods rawJS :: Text -> RawJavascript Source #
RawJS [Char] Source # |
Instance details Defined in Text.Julius Methods rawJS :: [Char] -> RawJavascript Source #

## Rendering Functions

renderJavascript :: Javascript -> Text Source #

renderJavascriptUrl :: (url -> [(Text, Text)] -> Text) -> JavascriptUrl url -> Text Source #

render with route interpolation. If using this module standalone, apart from type-safe routes, a dummy renderer can be used:

    renderJavascriptUrl (\_ _ -> undefined) javascriptUrl

When using Yesod, a renderer is generated for you, which can be accessed within the GHandler monad: `getUrlRenderParams`.

## internal, used by `Coffee`

javascriptSettings :: Q ShakespeareSettings Source #

## internal

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

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

asJavascriptUrl :: JavascriptUrl url -> JavascriptUrl url Source #