Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
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 {}
- 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
. See the Yesod book for details.JavascriptUrl
url
js :: QuasiQuoter Source #
julius :: QuasiQuoter Source #
Datatypes
type JavascriptUrl url = (url -> [(Text, Text)] -> Text) -> Javascript Source #
Return type of template-reading functions.
newtype Javascript Source #
Newtype wrapper of Builder
.
Instances
Monoid Javascript Source # | |
Defined in Text.Julius mempty :: Javascript # mappend :: Javascript -> Javascript -> Javascript # mconcat :: [Javascript] -> Javascript # | |
Semigroup Javascript Source # | |
Defined in Text.Julius (<>) :: Javascript -> Javascript -> Javascript # sconcat :: NonEmpty Javascript -> Javascript # stimes :: Integral b => b -> Javascript -> Javascript # |
newtype RawJavascript Source #
Instances
ToJavascript RawJavascript Source # | |
Defined in Text.Julius |
Typeclass for interpolated variables
class ToJavascript a where Source #
A typeclass for types that can be interpolated in CoffeeScript templates.
toJavascript :: a -> Javascript Source #
Instances
ToJavascript Value Source # | |
Defined in Text.Julius toJavascript :: Value -> Javascript Source # | |
ToJavascript RawJavascript Source # | |
Defined in Text.Julius | |
ToJavascript Text Source # | |
Defined in Text.Julius toJavascript :: Text -> Javascript Source # | |
ToJavascript Text Source # | |
Defined in Text.Julius toJavascript :: Text -> Javascript Source # | |
ToJavascript String Source # | |
Defined in Text.Julius toJavascript :: String -> Javascript Source # | |
ToJavascript Bool Source # | |
Defined in Text.Julius toJavascript :: Bool -> Javascript Source # |
rawJS :: a -> RawJavascript Source #
Instances
RawJS Text Source # | |
Defined in Text.Julius rawJS :: Text -> RawJavascript Source # | |
RawJS Builder Source # | |
Defined in Text.Julius rawJS :: Builder -> RawJavascript Source # | |
RawJS Text Source # | |
Defined in Text.Julius rawJS :: Text -> RawJavascript Source # | |
RawJS Bool Source # | |
Defined in Text.Julius rawJS :: Bool -> RawJavascript Source # | |
RawJS [Char] Source # | |
Defined in Text.Julius 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
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 #