[web-devel] questions about hamlet syntax, and yesod-examples-.

Michael Litchard michael at schmong.org
Wed Apr 13 01:04:54 CEST 2011

I'm using yesod 0.7.3, and I'm trying to change one of the yesod
examples to match the structure created by the scaffolding utility.
Here's the source of my confusion. This is what the sample hamlet file
looks like generated from the scaffold utility

        <title>#{pageTitle pc}
        ^{pageHead pc}
        $maybe msg <- mmsg
            <div #message>#{msg}
        ^{pageBody pc}

But here's a sample of the syntax used by yesod-examples

> instance Yesod Ajax where
>   approot _ = ""
>   defaultLayout widget = do
>   Ajax pages _ <- getYesod
>   content <- widgetToPageContent widget
>   hamletToRepHtml [$hamlet|
> \<!DOCTYPE html>
> <html>
>   <head>
>     <title>#{pageTitle content}
>     <link rel="stylesheet" href="@{StaticR style_css}">
>     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js">
>     <script src="@{StaticR script_js}">
>     \^{pageHead content}
>   <body>
>     <ul id="navbar">
>       $forall page <- pages
>         <li>
>           <a href="@{PageR (pageSlug page)}">#{pageName page}
>     <div id="content">
>       \^{pageBody content}
> |]

This doesn't look like the same syntax to me. Am I right? How would I
decouple the hamlet, as the scaffolding utility does?

More information about the web-devel mailing list