rendering "partials" in hakyll

44 views
Skip to first unread message

Greg

unread,
Oct 4, 2010, 11:53:30 PM10/4/10
to hakyll
I really like the capabilities that hakyll brings- creating static
sites with all the logic in the configuration file and nothing more
than simple variable substitution in the templating. But I am going to
keep complaining about the things I don't like :)

On my blog I would like to render a sidebar on each page that is
equivalent to the post listing on the index page

let renderSite template = renderChain (template:["templates/
default.html.hamlet"]) . withSidebar

That looks great!

let withSidebar = flip combine $ do
let list = createPostListing "dummy" (take 3
renderablePosts) [("title", Left "Recent Posts")]
let sidebar = renderAndConcat ["sidebar.html.hamlet"] [list]
createCustomPage "dummy" [("sidebar", Right sidebar)]
where
createPostListing url posts values =
createListing url ["templates/postitem.html.hamlet"] posts
values

Now I have 2 instance of "dummy" in one function, which makes me feel
like a dummy. Also I am using renderAndConcat which takes lits to
render multiple templates, but I only need to render one.

It is very possible that I still don't understand how hakyll is
supposed to be used. From my limited understanding, it seems that
hakyll works great for rendering templates into pages, but does not
work very easily for rendering "partials"- templates that will be
included into other templates.

My config file is dangerously close to violating Hakyll philosophy- it
is at 99 lines! Perhaps some partial rendering tools could help this
out.

Jasper Van der Jeugt

unread,
Oct 5, 2010, 3:15:46 AM10/5/10
to hak...@googlegroups.com
Hello,

Could you provide me with your entire hakyll.hs, so I can have a better look?

Cheers,
Jasper

Greg

unread,
Oct 5, 2010, 8:34:59 AM10/5/10
to hakyll

Jasper Van der Jeugt

unread,
Oct 31, 2010, 5:46:37 AM10/31/10
to hak...@googlegroups.com
Hello,

I think you could now use the `addField` function (Hakyll 2.4) to add
the sidebar.

Cheers,
Jasper

Reply all
Reply to author
Forward
0 new messages