Page generation error in 4.3.3.0

48 views
Skip to first unread message

Martin Hilscher

unread,
Sep 19, 2013, 9:40:08 AM9/19/13
to hak...@googlegroups.com
Hi,

does anybody have an explanation why the following works flawlessly in 4.3.0.0 and breaks with $posts$ being defined not defined 4.3.3.0?

    match "talks.html" $ do 
        route idRoute
        compile $ genCompiler tags (field "posts" $ \_ -> postList $ fmap (take 5) . (recentFirst >=> filterTalks))

filterByType :: (MonadMetadata m, Functor m) => String -> [Item String] -> m[Item String]
filterByType tpe = filterM hasType
              where
                hasType item = do
                    metadata <- getMetadata $ itemIdentifier item
                    let typ = Data.Map.lookup "type" metadata
                    return (typ == Just tpe)

filterTalks :: (MonadMetadata m, Functor m) => [Item String] -> m[Item String]
filterTalks = filterByType "talk"


postLst :: Pattern -> Identifier -> Context String -> ([Item String] -> Compiler [Item String]) -> Compiler String
postLst pattern template context sortFilter = do
    posts   <- return =<< sortFilter =<< loadAll pattern
    itemTpl <- loadBody template
    applyTemplateList itemTpl (teaserField "teaser" "teaser" `mappend` context) posts

postList :: ([Item String] -> Compiler [Item String]) -> Compiler String
postList = postLst "posts/*" "templates/post-item.html" postCtx


As I said it fails in the compile Line of the "talk" Rule and works like this in 4.3.0.0 and in 4.3 if i remove the "filterTalks" function and only go with recentFirst. If you need it the complete source code can be found here https://github.com/xinitrc/xinitrc.de

Best regards,
xinitrc

Jasper Van der Jeugt

unread,
Sep 20, 2013, 4:51:42 AM9/20/13
to hakyll
Hey xinitc,

Thanks for directly linking to your github repository, this made it
super convenient for me to reproduce the issue. :-)

Hakyll has a `-v` flag which usually helps tracking down these issues.
`./site build -v` gave me:

[DEBUG] Processing talks.html
[DEBUG] Hakyll.Core.Compiler.Internal: Alternative failed:
Hakyll.Web.Template.Context: no teaser defined for
posts/2013-05-31-AngularJS-talk.md
[DEBUG] Hakyll.Core.Compiler.Internal: Adding dependency:
IdentifierDependency posts/2013-05-31-AngularJS-talk.md
[DEBUG] Hakyll.Core.Compiler.Internal: Alternative failed: Missing
field $teaser$ in context for item posts/2013-05-31-AngularJS-talk.md
[DEBUG] Hakyll.Core.Compiler.Internal: Alternative failed: Missing
field $teaser$ in context for item posts/2013-05-31-AngularJS-talk.md
[DEBUG] Hakyll.Core.Compiler.Internal: Alternative failed: Missing
field $teaser$ in context for item posts/2013-05-31-AngularJS-talk.md
[ERROR] Missing field $posts$ in context for item talks.html

Meaning that $posts$ errors because the $teaser$ fails for your
AngularJS talk. This is a recent change I made to Hakyll, I didn't
realize I should've made it a major version bump. My apologies!

Basically the $teaser$ behavior changed: it will result in a failure
if it is not defined. This is more flexible, e.g. you can emulate the
old behavior with:

$if(teaser)$
$teaser$
$else$
$body$
$endif$

Hope this helps,
Peace,
Jasper
> --
> You received this message because you are subscribed to the Google Groups
> "hakyll" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to hakyll+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Martin Hilscher

unread,
Sep 20, 2013, 5:25:38 AM9/20/13
to hakyll
On 20 Sep 2013, at 10:51, Jasper Van der Jeugt wrote:

> Hope this helps,
> Peace,
> Jasper

Very much so Thank you. I probably wouldn't have found this ever.
Especially since I didn't know the -v flag.

With best regards,
xinitrc

---

Email is like Tetris, you loose eventually.
Reply all
Reply to author
Forward
0 new messages