Text.Julius

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

Safe Haskell | None
Language | Haskell98

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
- class RawJS a where
- 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 #

julius :: QuasiQuoter #

juliusFile :: FilePath -> Q Exp #

jsFile :: FilePath -> Q Exp #

juliusFileDebug :: FilePath -> Q Exp #

Deprecated: Please use juliusFileReload instead.

jsFileDebug :: FilePath -> Q Exp #

Deprecated: Please use jsFileReload instead.

juliusFileReload :: FilePath -> Q Exp #

jsFileReload :: FilePath -> Q Exp #

# Datatypes

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

Return type of template-reading functions.

newtype Javascript #

Newtype wrapper of `Builder`.

Constructors

Javascript |
Fields unJavascript :: Builder

Instances

Monoid Javascript # |
Methods mempty :: Javascript # mappend :: Javascript -> Javascript -> Javascript # mconcat :: [Javascript] -> Javascript #

newtype RawJavascript #

Constructors

RawJavascript Builder |

Instances

ToJavascript RawJavascript # |
Methods toJavascript :: RawJavascript -> Javascript #

# Typeclass for interpolated variables

class ToJavascript a where #

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

Minimal complete definition

toJavascript

Methods

toJavascript :: a -> Javascript #

Instances

ToJavascript Bool # |
Methods toJavascript :: Bool -> Javascript #
ToJavascript Value # |
Methods toJavascript :: Value -> Javascript #
ToJavascript RawJavascript # |
Methods toJavascript :: RawJavascript -> Javascript #

class RawJS a where #

Minimal complete definition

rawJS

Methods

rawJS :: a -> RawJavascript #

Instances

RawJS Bool # |
Methods rawJS :: Bool -> RawJavascript #
RawJS Builder # |
Methods rawJS :: Builder -> RawJavascript #
RawJS Text # |
Methods rawJS :: Text -> RawJavascript #
RawJS Text # |
Methods rawJS :: Text -> RawJavascript #
RawJS [Char] # |
Methods rawJS :: [Char] -> RawJavascript #

## Rendering Functions

renderJavascript :: Javascript -> Text #

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

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 #

## internal

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

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

asJavascriptUrl :: JavascriptUrl url -> JavascriptUrl url #