From 8a8dade15ffc84f543fc3774f7a0a8fac4835bd2 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Sun, 16 Dec 2012 00:21:59 +0100 Subject: Better tutorial structure --- web/tutorials/04-compilers.markdown | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 web/tutorials/04-compilers.markdown (limited to 'web/tutorials/04-compilers.markdown') diff --git a/web/tutorials/04-compilers.markdown b/web/tutorials/04-compilers.markdown new file mode 100644 index 0000000..a344c6e --- /dev/null +++ b/web/tutorials/04-compilers.markdown @@ -0,0 +1,38 @@ +--- +title: More on compilers: load, and templates +author: Jasper Van der Jeugt +--- + +Loading items +------------- + +The compiler Monad is a complex beast, but this is nicely hidden for the user of +the Hakyll library. + +Suppose that you're generating `index.html` which shows your latest brilliant +blogpost. This requires `posts/foo.markdown` to be generated *before* +`index.html` (so we don't have to generate it twice). But you don't have to care +about all of that: Hakyll will sort this out this out for you automatically! + +Let's see some quick examples. We can load a specific item: + +```haskell +load "posts/foo.markdown" :: Compiler (Item String) +``` + +Or a whole bunch of them: + +```haskell +loadAll "posts/*" :: Compiler [Item String] +``` + +Sometimes you just want the *contents* and not the `Item`: + +```haskell +loadBody "posts/foo.markdown" :: Compiler String +``` + +This is all useful if we want to use Hakyll's templating system. + +Basic templates +--------------- -- cgit v1.2.3