-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A toolkit for making compile-time interpolated templates -- -- Shakespeare is a family of type-safe, efficient template languages. -- Shakespeare templates are expanded at compile-time, ensuring that all -- interpolated variables are in scope. Variables are interpolated -- according to their type through a typeclass. -- -- Shakespeare templates can be used inline with a quasi-quoter or in an -- external file. -- -- Note there is no dependency on haskell-src-extras. Instead Shakespeare -- believes logic should stay out of templates and has its own minimal -- Haskell parser. -- -- Packages that use this: xml-hamlet -- -- Please see the documentation at -- http://www.yesodweb.com/book/shakespearean-templates for more -- details. @package shakespeare @version 2.0.21 -- | General parsers, functions and datatypes for all Shakespeare -- languages. module Text.Shakespeare.Base data Deref DerefModulesIdent :: [String] -> Ident -> Deref DerefIdent :: Ident -> Deref DerefIntegral :: Integer -> Deref DerefRational :: Rational -> Deref DerefString :: String -> Deref DerefBranch :: Deref -> Deref -> Deref DerefList :: [Deref] -> Deref DerefTuple :: [Deref] -> Deref newtype Ident Ident :: String -> Ident type Scope = [(Ident, Exp)] parseDeref :: UserParser a Deref parseHash :: UserParser a (Either String Deref) parseVar :: Char -> UserParser a (Either String Deref) parseVarString :: Char -> UserParser a (Either String String) parseAt :: UserParser a (Either String (Deref, Bool)) parseUrl :: Char -> Char -> UserParser a (Either String (Deref, Bool)) parseUrlString :: Char -> Char -> UserParser a (Either String String) parseCaret :: UserParser a (Either String Deref) parseUnder :: UserParser a (Either String Deref) parseInt :: Char -> UserParser a (Either String Deref) parseIntString :: Char -> UserParser a (Either String String) derefToExp :: Scope -> Deref -> Exp flattenDeref :: Deref -> Maybe [String] readUtf8File :: FilePath -> IO Text -- | Read file's content as String, converting newlines readUtf8FileString :: FilePath -> IO String -- | Embed file's content, converting newlines readFileQ :: FilePath -> Q String -- | Embed file's content, converting newlines and track file via ghc -- dependencies, recompiling on changes readFileRecompileQ :: FilePath -> Q String instance GHC.Classes.Ord Text.Shakespeare.Base.Deref instance Data.Data.Data Text.Shakespeare.Base.Deref instance GHC.Read.Read Text.Shakespeare.Base.Deref instance GHC.Classes.Eq Text.Shakespeare.Base.Deref instance GHC.Show.Show Text.Shakespeare.Base.Deref instance GHC.Classes.Ord Text.Shakespeare.Base.Ident instance Data.Data.Data Text.Shakespeare.Base.Ident instance GHC.Read.Read Text.Shakespeare.Base.Ident instance GHC.Classes.Eq Text.Shakespeare.Base.Ident instance GHC.Show.Show Text.Shakespeare.Base.Ident instance Language.Haskell.TH.Syntax.Lift Text.Shakespeare.Base.Deref instance Language.Haskell.TH.Syntax.Lift Text.Shakespeare.Base.Ident -- | NOTE: This module should be considered internal, and will be hidden in -- future releases. module Text.Shakespeare data ShakespeareSettings ShakespeareSettings :: Char -> Char -> Char -> Exp -> Exp -> Exp -> Bool -> Maybe PreConvert -> Maybe Exp -> ShakespeareSettings [varChar] :: ShakespeareSettings -> Char [urlChar] :: ShakespeareSettings -> Char [intChar] :: ShakespeareSettings -> Char [toBuilder] :: ShakespeareSettings -> Exp [wrap] :: ShakespeareSettings -> Exp [unwrap] :: ShakespeareSettings -> Exp [justVarInterpolation] :: ShakespeareSettings -> Bool [preConversion] :: ShakespeareSettings -> Maybe PreConvert -- | A transformation applied to the final expression. Most often, this -- would be used to force the type of the expression to help make more -- meaningful error messages. [modifyFinalValue] :: ShakespeareSettings -> Maybe Exp -- | Coffeescript, TypeScript, and other languages compiles down to -- Javascript. Previously we waited until the very end, at the rendering -- stage to perform this compilation. Lets call is a post-conversion This -- had the advantage that all Haskell values were inserted first: for -- example a value could be inserted that Coffeescript would compile into -- Javascript. While that is perhaps a safer approach, the advantage is -- not used in practice: it was that way mainly for ease of -- implementation. The down-side is the template must be compiled down to -- Javascript during every request. If instead we do a pre-conversion to -- compile down to Javascript, we only need to perform the compilation -- once. -- -- The problem then is the insertion of Haskell values: we need a hole -- for them. This can be done with variables known to the language. -- During the pre-conversion we first modify all Haskell insertions So -- #{a} is change to shakespeare_var_a Then we can place the Haskell -- values in a function wrapper that exposes those variables: -- (function(shakespeare_var_a){ ... shakespeare_var_a ...}) TypeScript -- can compile that, and then we tack an application of the Haskell -- values onto the result: (#{a}) -- -- preEscapeIgnoreBalanced is used to not insert backtacks for variable -- already inside strings or backticks. coffeescript will happily ignore -- the interpolations, and backticks would not be treated as escaping in -- that context. preEscapeIgnoreLine was added to ignore comments (which -- in Coffeescript begin with a #) data PreConvert PreConvert :: PreConversion -> [Char] -> [Char] -> Maybe WrapInsertion -> PreConvert [preConvert] :: PreConvert -> PreConversion [preEscapeIgnoreBalanced] :: PreConvert -> [Char] [preEscapeIgnoreLine] :: PreConvert -> [Char] [wrapInsertion] :: PreConvert -> Maybe WrapInsertion data WrapInsertion WrapInsertion :: Maybe String -> String -> String -> String -> String -> Bool -> WrapInsertion [wrapInsertionIndent] :: WrapInsertion -> Maybe String [wrapInsertionStartBegin] :: WrapInsertion -> String [wrapInsertionSeparator] :: WrapInsertion -> String [wrapInsertionStartClose] :: WrapInsertion -> String [wrapInsertionEnd] :: WrapInsertion -> String [wrapInsertionAddParens] :: WrapInsertion -> Bool data PreConversion ReadProcess :: String -> [String] -> PreConversion Id :: PreConversion defaultShakespeareSettings :: ShakespeareSettings shakespeare :: ShakespeareSettings -> QuasiQuoter shakespeareFile :: ShakespeareSettings -> FilePath -> Q Exp shakespeareFileReload :: ShakespeareSettings -> FilePath -> Q Exp shakespeareFromString :: ShakespeareSettings -> String -> Q Exp -- | Determine which identifiers are used by the given template, useful for -- creating systems like yesod devel. shakespeareUsedIdentifiers :: ShakespeareSettings -> String -> [(Deref, VarType)] type RenderUrl url = (url -> QueryParameters -> Text) data VarType VTPlain :: VarType VTUrl :: VarType VTUrlParam :: VarType VTMixin :: VarType data Deref -- | A parser with a user state of [String] type Parser = Parsec String [String] preFilter :: Maybe FilePath -> ShakespeareSettings -> String -> IO String shakespeareRuntime :: ShakespeareSettings -> FilePath -> [(Deref, VarExp url)] -> Shakespeare url pack' :: String -> Text instance GHC.Generics.Generic Text.Shakespeare.VarType instance Data.Data.Data Text.Shakespeare.VarType instance GHC.Enum.Bounded Text.Shakespeare.VarType instance GHC.Enum.Enum Text.Shakespeare.VarType instance GHC.Classes.Ord Text.Shakespeare.VarType instance GHC.Classes.Eq Text.Shakespeare.VarType instance GHC.Show.Show Text.Shakespeare.VarType instance GHC.Classes.Eq Text.Shakespeare.Content instance GHC.Show.Show Text.Shakespeare.Content instance Language.Haskell.TH.Syntax.Lift Text.Shakespeare.ShakespeareSettings instance Language.Haskell.TH.Syntax.Lift Text.Shakespeare.PreConvert instance Language.Haskell.TH.Syntax.Lift Text.Shakespeare.PreConversion instance Language.Haskell.TH.Syntax.Lift Text.Shakespeare.WrapInsertion -- | 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 module Text.Julius js :: QuasiQuoter julius :: QuasiQuoter juliusFile :: FilePath -> Q Exp jsFile :: FilePath -> Q Exp -- | Deprecated: Please use juliusFileReload instead. juliusFileDebug :: FilePath -> Q Exp -- | Deprecated: Please use jsFileReload instead. jsFileDebug :: FilePath -> Q Exp juliusFileReload :: FilePath -> Q Exp jsFileReload :: FilePath -> Q Exp -- | Return type of template-reading functions. type JavascriptUrl url = (url -> [(Text, Text)] -> Text) -> Javascript -- | Newtype wrapper of Builder. newtype Javascript Javascript :: Builder -> Javascript [unJavascript] :: Javascript -> Builder newtype RawJavascript RawJavascript :: Builder -> RawJavascript -- | A typeclass for types that can be interpolated in CoffeeScript -- templates. class ToJavascript a toJavascript :: ToJavascript a => a -> Javascript class RawJS a rawJS :: RawJS a => a -> RawJavascript renderJavascript :: Javascript -> 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. renderJavascriptUrl :: (url -> [(Text, Text)] -> Text) -> JavascriptUrl url -> Text javascriptSettings :: Q ShakespeareSettings -- | Determine which identifiers are used by the given template, useful for -- creating systems like yesod devel. juliusUsedIdentifiers :: String -> [(Deref, VarType)] asJavascriptUrl :: JavascriptUrl url -> JavascriptUrl url instance GHC.Base.Monoid Text.Julius.Javascript instance GHC.Base.Semigroup Text.Julius.Javascript instance Text.Julius.RawJS [GHC.Types.Char] instance Text.Julius.RawJS Data.Text.Internal.Text instance Text.Julius.RawJS Data.Text.Internal.Lazy.Text instance Text.Julius.RawJS Data.Text.Internal.Builder.Builder instance Text.Julius.RawJS GHC.Types.Bool instance Text.Julius.ToJavascript Text.Julius.RawJavascript instance Text.Julius.ToJavascript GHC.Types.Bool instance Text.Julius.ToJavascript Data.Aeson.Types.Internal.Value instance Text.Julius.ToJavascript GHC.Base.String instance Text.Julius.ToJavascript Data.Text.Internal.Text instance Text.Julius.ToJavascript Data.Text.Internal.Lazy.Text -- | A Shakespearean module for Roy, introducing type-safe, compile-time -- variable and url interpolation. It is exactly the same as -- Text.Julius, except that the template is first compiled to -- Javascript with the system tool roy. -- -- To use this module, roy must be installed on your system. -- -- If you interpolate variables, the template is first wrapped with a -- function containing javascript variables representing shakespeare -- variables, then compiled with roy, and then the value of the -- variables are applied to the function. This means that in production -- the template can be compiled once at compile time and there will be no -- dependency in your production system on roy. -- -- Your code: -- --
-- let b = 1
-- console.log(#{a} + b)
--
--
-- Final Result:
--
--
-- ;(function(shakespeare_var_a){
-- var b = 1;
-- console.log(shakespeare_var_a + b);
-- })(#{a});
--
--
-- Further reading:
--
--
-- b = 1
-- console.log(#{a} + b)
--
--
-- Function wrapper added to your coffeescript code:
--
-- -- ((shakespeare_var_a) => -- b = 1 -- console.log(shakespeare_var_a + b) -- ) ---- -- This is then compiled down to javascript, and the variables are -- applied: -- --
-- ;(function(shakespeare_var_a){
-- var b = 1;
-- console.log(shakespeare_var_a + b);
-- })(#{a});
--
--
-- Further reading:
--
--
-- >>> renderCss ([lucius|foo{bar:baz}|] undefined)
-- "foo{bar:baz}"
--
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])
-- | Same as luciusRT, but output has no added whitespace.
--
-- Since 1.0.3
luciusRTMinified :: Text -> [(Text, Text)] -> Either String Text
-- | Runtime Lucius with mixin support.
--
-- Since 1.0.6
luciusRTMixin :: Text -> Bool -> [(Text, RTValue)] -> Either String Text
data RTValue
RTVRaw :: Text -> RTValue
RTVMixin :: Mixin -> RTValue
data Css
type CssUrl url = (url -> [(Text, Text)] -> Text) -> Css
class ToCss a
toCss :: ToCss a => a -> Builder
renderCss :: Css -> Text
renderCssUrl :: (url -> [(Text, Text)] -> Text) -> CssUrl url -> Text
data Color
Color :: Word8 -> Word8 -> Word8 -> Color
colorRed :: Color
colorBlack :: Color
-- | Create a CSS size, e.g. $(mkSize "100px").
mkSize :: String -> ExpQ
-- | Absolute size units.
data AbsoluteUnit
Centimeter :: AbsoluteUnit
Inch :: AbsoluteUnit
Millimeter :: AbsoluteUnit
Pica :: AbsoluteUnit
Point :: AbsoluteUnit
-- | Not intended for direct use, see mkSize.
data AbsoluteSize
AbsoluteSize :: AbsoluteUnit -> Rational -> AbsoluteSize
-- | Units used for text formatting.
[absoluteSizeUnit] :: AbsoluteSize -> AbsoluteUnit
-- | Normalized value in centimeters.
[absoluteSizeValue] :: AbsoluteSize -> Rational
-- | Constructs AbsoluteSize. Not intended for direct use, see
-- mkSize.
absoluteSize :: AbsoluteUnit -> Rational -> AbsoluteSize
data EmSize
EmSize :: Rational -> EmSize
data ExSize
ExSize :: Rational -> ExSize
-- | Not intended for direct use, see mkSize.
data PercentageSize
PercentageSize :: Rational -> PercentageSize
-- | Normalized value, 1 == 100%.
[percentageSizeValue] :: PercentageSize -> Rational
-- | Constructs PercentageSize. Not intended for direct use, see
-- mkSize.
percentageSize :: Rational -> PercentageSize
data PixelSize
PixelSize :: Rational -> PixelSize
parseTopLevels :: Parser [TopLevel Unresolved]
-- | Determine which identifiers are used by the given template, useful for
-- creating systems like yesod devel.
luciusUsedIdentifiers :: String -> [(Deref, VarType)]
-- | Provides functionality for runtime Hamlet templates. Please use
-- Text.Hamlet.Runtime instead.
module Text.Hamlet.RT
newtype HamletRT
HamletRT :: [SimpleDoc] -> HamletRT
data HamletData url
HDHtml :: Html -> HamletData url
HDUrl :: url -> HamletData url
HDUrlParams :: url -> [(Text, Text)] -> HamletData url
HDTemplate :: HamletRT -> HamletData url
HDBool :: Bool -> HamletData url
HDMaybe :: Maybe (HamletMap url) -> HamletData url
HDList :: [HamletMap url] -> HamletData url
type HamletMap url = [([String], HamletData url)]
data HamletException
HamletParseException :: String -> HamletException
HamletUnsupportedDocException :: Doc -> HamletException
HamletRenderException :: String -> HamletException
parseHamletRT :: MonadThrow m => HamletSettings -> String -> m HamletRT
renderHamletRT :: MonadThrow m => HamletRT -> HamletMap url -> UrlRenderer url -> m Html
renderHamletRT' :: MonadThrow m => Bool -> HamletRT -> HamletMap url -> (url -> [(Text, Text)] -> Text) -> m Html
data SimpleDoc
SDRaw :: String -> SimpleDoc
SDVar :: [String] -> SimpleDoc
SDUrl :: Bool -> [String] -> SimpleDoc
SDTemplate :: [String] -> SimpleDoc
SDForall :: [String] -> String -> [SimpleDoc] -> SimpleDoc
SDMaybe :: [String] -> String -> [SimpleDoc] -> [SimpleDoc] -> SimpleDoc
SDCond :: [([String], [SimpleDoc])] -> [SimpleDoc] -> SimpleDoc
instance GHC.Show.Show Text.Hamlet.RT.HamletException
instance GHC.Exception.Type.Exception Text.Hamlet.RT.HamletException
module Text.Hamlet
type Html = Markup
-- | "Simple Hamlet" quasi-quoter. May only be used to generate
-- expressions.
--
-- Generated expressions have type Html.
--
-- -- >>> putStrLn (renderHtml [shamlet|<div>Hello, world!|]) -- <div>Hello, world!</div> --shamlet :: QuasiQuoter shamletFile :: FilePath -> Q Exp -- | Like shamlet, but produces XHTML. xshamlet :: QuasiQuoter -- | Like shamletFile, but produces XHTML. xshamletFile :: FilePath -> Q Exp -- | A function generating an Html given a URL-rendering function. type HtmlUrl url = Render url -> Html type Render url = url -> [(Text, Text)] -> Text -- | Hamlet quasi-quoter. May only be used to generate expressions. -- -- Generated expression have type HtmlUrl url, for some -- url. -- --
-- data MyRoute = Home
--
-- render :: Render MyRoute
-- render Home _ = "/home"
--
-- >>> putStrLn (renderHtml ([hamlet|<a href=@{Home}>Home|] render))
-- <a href="/home">Home</a>
--
hamlet :: QuasiQuoter
hamletFile :: FilePath -> Q Exp
-- | Like hamletFile, but the external file is parsed at runtime.
-- Allows for more rapid development, but should not be used in
-- production.
hamletFileReload :: FilePath -> Q Exp
-- | Like hamlet, but produces XHTML.
xhamlet :: QuasiQuoter
-- | Like hamletFile, but produces XHTML.
xhamletFile :: FilePath -> Q Exp
-- | A function generating an Html given a message translator and a
-- URL rendering function.
type HtmlUrlI18n msg url = Translate msg -> Render url -> Html
type Translate msg = msg -> Html
-- | Hamlet quasi-quoter with internationalization. May only be used to
-- generate expressions.
--
-- Generated expressions have type HtmlUrlI18n msg url,
-- for some msg and url.
--
--
-- data MyMsg = Hi | Bye
--
-- data MyRoute = Home
--
-- renderEnglish :: Translate MyMsg
-- renderEnglish Hi = "hi"
-- renderEnglish Bye = "bye"
--
-- renderUrl :: Render MyRoute
-- renderUrl Home _ = "/home"
--
-- >>> putStrLn (renderHtml ([ihamlet|@{Home} _{Hi} _{Bye}|] renderEnglish renderUrl))
-- <div>/home hi bye <div>
--
ihamlet :: QuasiQuoter
ihamletFile :: FilePath -> Q Exp
-- | Like ihamletFile, but the external file is parsed at runtime.
-- Allows for more rapid development, but should not be used in
-- production.
ihamletFileReload :: FilePath -> Q Exp
-- | Convert some value to a list of attribute pairs.
class ToAttributes a
toAttributes :: ToAttributes a => a -> [(Text, Text)]
-- | Settings for parsing of a hamlet document.
data HamletSettings
HamletSettings :: String -> NewlineStyle -> (String -> CloseStyle) -> [(String, String)] -> HamletSettings
-- | The value to replace a "!!!" with. Do not include the trailing
-- newline.
[hamletDoctype] :: HamletSettings -> String
-- | Should we add newlines to the output, making it more human-readable?
-- Useful for client-side debugging but may alter browser page layout.
[hamletNewlines] :: HamletSettings -> NewlineStyle
-- | How a tag should be closed. Use this to switch between HTML, XHTML or
-- even XML output.
[hamletCloseStyle] :: HamletSettings -> String -> CloseStyle
-- | Mapping from short names in "$doctype" statements to full doctype.
[hamletDoctypeNames] :: HamletSettings -> [(String, String)]
data NewlineStyle
-- | never add newlines
NoNewlines :: NewlineStyle
-- | add newlines between consecutive text lines
NewlinesText :: NewlineStyle
-- | add newlines everywhere
AlwaysNewlines :: NewlineStyle
DefaultNewlineStyle :: NewlineStyle
hamletWithSettings :: Q HamletRules -> HamletSettings -> QuasiQuoter
hamletFileWithSettings :: Q HamletRules -> HamletSettings -> FilePath -> Q Exp
-- | Defaults settings: HTML5 doctype and HTML-style empty tags.
defaultHamletSettings :: HamletSettings
xhtmlHamletSettings :: HamletSettings
data Env
Env :: Maybe ((Exp -> Q Exp) -> Q Exp) -> Maybe ((Exp -> Q Exp) -> Q Exp) -> Env
[urlRender] :: Env -> Maybe ((Exp -> Q Exp) -> Q Exp)
[msgRender] :: Env -> Maybe ((Exp -> Q Exp) -> Q Exp)
data HamletRules
HamletRules :: Exp -> ((Env -> Q Exp) -> Q Exp) -> (Env -> Exp -> Q Exp) -> HamletRules
[hrFromHtml] :: HamletRules -> Exp
[hrWithEnv] :: HamletRules -> (Env -> Q Exp) -> Q Exp
[hrEmbed] :: HamletRules -> Env -> Exp -> Q Exp
hamletRules :: Q HamletRules
ihamletRules :: Q HamletRules
htmlRules :: Q HamletRules
data CloseStyle
NoClose :: CloseStyle
CloseInside :: CloseStyle
CloseSeparate :: CloseStyle
-- | Checks for truth in the left value in each pair in the first argument.
-- If a true exists, then the corresponding right action is performed.
-- Only the first is performed. In there are no true values, then the
-- second argument is performed, if supplied.
condH :: Monad m => [(Bool, m ())] -> Maybe (m ()) -> m ()
-- | Runs the second argument with the value in the first, if available.
-- Otherwise, runs the third argument, if available.
maybeH :: Monad m => Maybe v -> (v -> m ()) -> Maybe (m ()) -> m ()
asHtmlUrl :: HtmlUrl url -> HtmlUrl url
attrsToHtml :: [(Text, Text)] -> Html
hamletFromString :: Q HamletRules -> HamletSettings -> String -> Q Exp
instance GHC.Show.Show (Text.Hamlet.VarExp msg url)
instance Text.Hamlet.ToAttributes (Data.Text.Internal.Text, Data.Text.Internal.Text)
instance Text.Hamlet.ToAttributes (GHC.Base.String, GHC.Base.String)
instance Text.Hamlet.ToAttributes [(Data.Text.Internal.Text, Data.Text.Internal.Text)]
instance Text.Hamlet.ToAttributes [(GHC.Base.String, GHC.Base.String)]
-- | Module for parsing and rendering Hamlet templates at runtime, not
-- compile time. This uses the same Hamlet parsing as compile-time
-- Hamlet, but has some limitations, such as:
--
--
-- {-# LANGUAGE OverloadedStrings #-}
-- import Text.Hamlet.Runtime
-- import qualified Data.Map as Map
-- import Text.Blaze.Html.Renderer.String (renderHtml)
--
-- main :: IO ()
-- main = do
-- template <- parseHamletTemplate defaultHamletSettings $ unlines
-- [ "<p>Hello, #{name}"
-- , "$if hungry"
-- , " <p>Available food:"
-- , " <ul>"
-- , " $forall food <- foods"
-- , " <li>#{food}"
-- ]
-- let hamletDataMap = Map.fromList
-- [ ("name", "Michael")
-- , ("hungry", toHamletData True) -- always True
-- , ("foods", toHamletData
-- [ "Apples"
-- , "Bananas"
-- , "Carrots"
-- ])
-- ]
-- html <- renderHamletTemplate template hamletDataMap
-- putStrLn $ renderHtml html
--
module Text.Hamlet.Runtime
-- | A parsed Hamlet template. See parseHamletTemplate and
-- readHamletTemplateFile.
data HamletTemplate
-- | Settings for parsing of a hamlet document.
data HamletSettings
-- | Defaults settings: HTML5 doctype and HTML-style empty tags.
defaultHamletSettings :: HamletSettings
-- | A piece of data that can be embedded and passed to a Hamlet template
-- (via renderHamletTemplate).
--
-- This supplies an IsString instance, so with
-- OverloadedStrings it will support literal strings, which are
-- converted to HTML via toHtml. For other datatypes, use
-- toHamletData.
data HamletData
-- | Data which can be passed to a Hamlet template.
class ToHamletData a
toHamletData :: ToHamletData a => a -> HamletData
-- | Parse an in-memory Hamlet template. This operation may fail if the
-- template is not parsable.
parseHamletTemplate :: MonadThrow m => HamletSettings -> String -> m HamletTemplate
-- | Same as parseHamletTemplate, but reads from a file. The file is
-- assumed to be UTF-8 encoded (same assumption as compile-time Hamlet).
readHamletTemplateFile :: (MonadThrow m, MonadIO m) => HamletSettings -> FilePath -> m HamletTemplate
-- | Render a runtime Hamlet template, together with a Map of
-- variables to pass in, into an Html value. This can fail if the
-- template references a variable that is not present in the
-- Map.
renderHamletTemplate :: MonadThrow m => HamletTemplate -> Map Text HamletData -> m Html
instance Text.Hamlet.Runtime.ToHamletData Text.Hamlet.Runtime.HamletData
instance (a Data.Type.Equality.~ Text.Hamlet.Runtime.HamletData) => Text.Hamlet.Runtime.ToHamletData [a]
instance (a Data.Type.Equality.~ Text.Hamlet.Runtime.HamletData) => Text.Hamlet.Runtime.ToHamletData (GHC.Maybe.Maybe a)
instance Text.Hamlet.Runtime.ToHamletData Data.Text.Internal.Text
instance Text.Hamlet.Runtime.ToHamletData Text.Blaze.Html.Html
instance Text.Hamlet.Runtime.ToHamletData GHC.Types.Bool
instance Data.String.IsString Text.Hamlet.Runtime.HamletData
module Text.Cassius
data Css
type CssUrl url = (url -> [(Text, Text)] -> Text) -> Css
class ToCss a
toCss :: ToCss a => a -> Builder
renderCss :: Css -> Text
renderCssUrl :: (url -> [(Text, Text)] -> Text) -> CssUrl url -> Text
cassius :: QuasiQuoter
cassiusFile :: FilePath -> Q Exp
cassiusFileDebug :: FilePath -> Q Exp
cassiusFileReload :: FilePath -> Q Exp
-- | Create a mixin with Cassius syntax.
--
-- Since 2.0.3
cassiusMixin :: QuasiQuoter
data Mixin
data Color
Color :: Word8 -> Word8 -> Word8 -> Color
colorRed :: Color
colorBlack :: Color
-- | Create a CSS size, e.g. $(mkSize "100px").
mkSize :: String -> ExpQ
-- | Absolute size units.
data AbsoluteUnit
Centimeter :: AbsoluteUnit
Inch :: AbsoluteUnit
Millimeter :: AbsoluteUnit
Pica :: AbsoluteUnit
Point :: AbsoluteUnit
-- | Not intended for direct use, see mkSize.
data AbsoluteSize
AbsoluteSize :: AbsoluteUnit -> Rational -> AbsoluteSize
-- | Units used for text formatting.
[absoluteSizeUnit] :: AbsoluteSize -> AbsoluteUnit
-- | Normalized value in centimeters.
[absoluteSizeValue] :: AbsoluteSize -> Rational
-- | Constructs AbsoluteSize. Not intended for direct use, see
-- mkSize.
absoluteSize :: AbsoluteUnit -> Rational -> AbsoluteSize
data EmSize
EmSize :: Rational -> EmSize
data ExSize
ExSize :: Rational -> ExSize
-- | Not intended for direct use, see mkSize.
data PercentageSize
PercentageSize :: Rational -> PercentageSize
-- | Normalized value, 1 == 100%.
[percentageSizeValue] :: PercentageSize -> Rational
-- | Constructs PercentageSize. Not intended for direct use, see
-- mkSize.
percentageSize :: Rational -> PercentageSize
data PixelSize
PixelSize :: Rational -> PixelSize
-- | Determine which identifiers are used by the given template, useful for
-- creating systems like yesod devel.
cassiusUsedIdentifiers :: String -> [(Deref, VarType)]
-- | This module provides a type-based system for providing translations
-- for text strings.
--
-- It is similar in purpose to gettext or Java message bundles.
--
-- The core idea is to create simple data type where each constructor
-- represents a phrase, sentence, paragraph, etc. For example:
--
-- -- data AppMessages = Hello | Goodbye ---- -- The RenderMessage class is used to retrieve the appropriate -- translation for a message value: -- --
-- class RenderMessage master message where -- renderMessage :: master -- ^ type that specifies which set of translations to use -- -> [Lang] -- ^ acceptable languages in descending order of preference -- -> message -- ^ message to translate -- -> Text ---- -- Defining the translation type and providing the RenderMessage -- instance in Haskell is not very translator friendly. Instead, -- translations are generally provided in external translations files. -- Then the mkMessage Template Haskell function is used to read -- the external translation files and automatically create the -- translation type and the RenderMessage instance. -- -- A full description of using this module to create translations for -- Hamlet can be found here: -- -- http://www.yesodweb.com/book/internationalization -- -- A full description of using the module to create translations for -- HSP can be found here: -- -- http://happstack.com/docs/crashcourse/Templates.html#hsp-i18n -- -- You can also adapt those instructions for use with other systems. module Text.Shakespeare.I18N -- | generate translations from translation files -- -- This function will: -- --
-- λ> :set -XQuasiQuotes
-- λ> let bar = 23 :: Int in [st|#{bar}|] :: Text
--
--
-- produces "23", but
--
--
-- λ> let bar = 23 :: Int in [st|#\{bar}|] :: Text
--
--
-- returns "#{bar}". The escaping backslash is removed from the output.
--
-- Further reading: Shakespearean templates:
-- https://www.yesodweb.com/book/shakespearean-templates
module Text.Shakespeare.Text
type TextUrl url = RenderUrl url -> Builder
class ToText a
toText :: ToText a => a -> Builder
renderTextUrl :: RenderUrl url -> TextUrl url -> Text
stext :: QuasiQuoter
text :: QuasiQuoter
textFile :: FilePath -> Q Exp
-- | Deprecated: Please use textFileReload instead
textFileDebug :: FilePath -> Q Exp
textFileReload :: FilePath -> Q Exp
st :: QuasiQuoter
lt :: QuasiQuoter
sbt :: QuasiQuoter
lbt :: QuasiQuoter
-- | codegen is designed for generating Yesod code, including templates So
-- it uses different interpolation characters that won't clash with
-- templates. You can use the normal text quasiquoters to generate code
codegen :: QuasiQuoter
-- | Generates strict Text codegen is designed for generating Yesod code,
-- including templates So it uses different interpolation characters that
-- won't clash with templates.
codegenSt :: QuasiQuoter
codegenFile :: FilePath -> Q Exp
codegenFileReload :: FilePath -> Q Exp
instance Text.Shakespeare.Text.ToText Data.Text.Internal.Builder.Builder
instance Text.Shakespeare.Text.ToText [GHC.Types.Char]
instance Text.Shakespeare.Text.ToText Data.Text.Internal.Text
instance Text.Shakespeare.Text.ToText Data.Text.Internal.Lazy.Text
instance Text.Shakespeare.Text.ToText GHC.Int.Int32
instance Text.Shakespeare.Text.ToText GHC.Int.Int64
instance Text.Shakespeare.Text.ToText GHC.Types.Int
-- | A Shakespearean module for TypeScript, introducing type-safe,
-- compile-time variable and url interpolation. It is exactly the same as
-- Text.Julius, except that the template is first compiled to
-- Javascript with the system tool tsc.
--
-- To use this module, tsc must be installed on your system.
--
-- If you interpolate variables, the template is first wrapped with a
-- function containing javascript variables representing shakespeare
-- variables, then compiled with tsc, and then the value of the
-- variables are applied to the function. This means that in production
-- the template can be compiled once at compile time and there will be no
-- dependency in your production system on tsc.
--
-- Your code:
--
--
-- var b = 1
-- console.log(#{a} + b)
--
--
-- Final Result:
--
--
-- ;(function(shakespeare_var_a){
-- var b = 1;
-- console.log(shakespeare_var_a + b);
-- })(#{a});
--
--
-- Important Warnings! This integration is not ideal.
--
-- Due to the function wrapper, all type declarations must be in separate
-- .d.ts files. However, if you don't interpolate variables, no function
-- wrapper will be created, and you can make type declarations in the
-- same file.
--
-- This does not work cross-platform!
--
-- Unfortunately tsc does not support stdin and stdout. So a hack of
-- writing to temporary files using the mktemp command is used. This
-- works on my version of Linux, but not for windows unless perhaps you
-- install a mktemp utility, which I have not tested. Please vote up this
-- bug: http://typescript.codeplex.com/workitem/600
--
-- Making this work on Windows would not be very difficult, it will just
-- require a new package with a dependency on a package like temporary.
--
-- Further reading:
--
--