Safe Haskell | None |
---|---|
Language | Haskell2010 |
- compileTemplate' :: FilePath -> Action Template
- type PandocReader textType = textType -> PandocIO Pandoc
- type PandocWriter = Pandoc -> PandocIO Text
- markdownToHTML :: Text -> Action Value
- markdownToHTML' :: FromJSON a => Text -> Action a
- makePandocReader :: PandocReader textType -> textType -> Action (Pandoc, Value)
- makePandocReader' :: FromJSON a => PandocReader textType -> textType -> Action (Pandoc, a)
- loadUsing :: PandocReader textType -> PandocWriter -> textType -> Action Value
- loadUsing' :: FromJSON a => PandocReader textType -> PandocWriter -> textType -> Action a
- markdownOptions :: ReaderOptions
- html5Options :: WriterOptions
- convert :: (FromJSON a, ToJSON a, FromJSON b) => a -> Action b
- simpleJsonCache :: ShakeValue q => q -> Action Value -> Rules (Action Value)
- simpleJsonCache' :: forall q a. (ToJSON a, FromJSON a, ShakeValue q) => q -> Action a -> Rules (Action a)
- jsonCache :: ShakeValue q => (q -> Action Value) -> Rules (q -> Action Value)
- jsonCache' :: forall a q. (ToJSON a, FromJSON a, ShakeValue q) => (q -> Action a) -> Rules (q -> Action a)
Slick
This module re-exports everything you need to use Slick
Mustache
compileTemplate' :: FilePath -> Action Template Source #
Like compileTemplate
but tracks changes to template files and partials
within Shake.
Pandoc
type PandocReader textType = textType -> PandocIO Pandoc Source #
type PandocWriter = Pandoc -> PandocIO Text Source #
markdownToHTML :: Text -> Action Value Source #
Convert markdown text into a Value
;
The Value
has a "content" key containing rendered HTML
Metadata is assigned on the respective keys in the Value
markdownToHTML' :: FromJSON a => Text -> Action a Source #
Like markdownToHTML
but allows returning any JSON serializable object
makePandocReader :: PandocReader textType -> textType -> Action (Pandoc, Value) Source #
Given a reader from Readers
this creates a loader which
given the source document will read its metadata into a Value
returning both the Pandoc
object and the metadata within an Action
makePandocReader' :: FromJSON a => PandocReader textType -> textType -> Action (Pandoc, a) Source #
Like makePandocReader
but will deserialize the metadata into any object
which implements FromJSON
. Failure to deserialize will fail the Shake
build.
loadUsing :: PandocReader textType -> PandocWriter -> textType -> Action Value Source #
Load in a source document using the given PandocReader
, then render the Pandoc
into text using the given PandocWriter
.
Returns a Value
wherein the rendered text is set to the "content" key and
any metadata is set to its respective key in the Value
loadUsing' :: FromJSON a => PandocReader textType -> PandocWriter -> textType -> Action a Source #
Like loadUsing
but allows also deserializes the Value
into any object
which implements FromJSON
. Failure to deserialize will fail the Shake
build.
markdownOptions :: ReaderOptions Source #
Reasonable options for reading a markdown file
html5Options :: WriterOptions Source #
Reasonable options for rendering to HTML
Aeson
convert :: (FromJSON a, ToJSON a, FromJSON b) => a -> Action b Source #
Attempt to convert between two JSON serializable objects (or Value
s).
Failure to deserialize fails the Shake build.
Shake
simpleJsonCache :: ShakeValue q => q -> Action Value -> Rules (Action Value) Source #
A wrapper around jsonCache
which simplifies caching of values which do NOT
depend on an input parameter. Unfortunately Shake still requires that the
key type implement several typeclasses, however this is easily accomplished
using GeneralizedNewtypeDeriving
and a wrapper around ()
.
example usage:
{-# LANGUAGE GeneralizedNewtypeDeriving #-} module Main where newtype ProjectList = ProjectList () deriving (Show, Eq, Hashable, Binary, NFData)
Within your shake Rules:
projectCache = simpleJsonCache (ProjectList ()) $ do -- load your project list here; returning it as a Value
simpleJsonCache' :: forall q a. (ToJSON a, FromJSON a, ShakeValue q) => q -> Action a -> Rules (Action a) Source #
Like simpleJsonCache
but allows caching any JSON serializable object.
jsonCache :: ShakeValue q => (q -> Action Value) -> Rules (q -> Action Value) Source #
A wrapper around addOracleCache
which given a q
which is a ShakeValue
allows caching and retrieving Value
s within Shake. See documentation on
addOracleCache
or see Slick examples for more info.
-- We need to define a unique datatype as our cache key newtype PostFilePath = PostFilePath String -- We can derive the classes we need (using GeneralizedNewtypeDeriving) -- so long as the underlying type implements them deriving (Show, Eq, Hashable, Binary, NFData) -- now in our shake rules we can create a cache by providing a loader action do postCache <- jsonCache $ \(PostFilePath path) -> readFile' path >>= markdownToHTML . Text.pack -- Now use postCache inside an Action to load your post with caching!
jsonCache' :: forall a q. (ToJSON a, FromJSON a, ShakeValue q) => (q -> Action a) -> Rules (q -> Action a) Source #
Like jsonCache
but allows caching/retrieving any JSON serializable
objects.