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

Greg Weber greg at gregweber.info
Wed Apr 13 01:35:44 CEST 2011


It is the same syntax. The closing bracket, '>' is optional if there is no
inner text. The principle of hamlet is to make any redundant part of html
optional, and to remove closing tags in favor of indentation. We are
considering always using the closing bracket for examples to make It easier
to digest for newcomers. It also makes for easier use of some html syntax
highlighters (vim works well enough for me).

On Tue, Apr 12, 2011 at 4:04 PM, Michael Litchard <michael at schmong.org>wrote:

> 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
>
> !!!
> <html
>    <head
>        <title>#{pageTitle pc}
>        ^{pageHead pc}
>    <body
>        $maybe msg <- mmsg
>            <div #message>#{msg}
>        ^{pageBody pc}
>
> But here's a sample of the syntax used by yesod-examples 0.7.0.1
>
> > 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?
>
> _______________________________________________
> web-devel mailing list
> web-devel at haskell.org
> http://www.haskell.org/mailman/listinfo/web-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/web-devel/attachments/20110412/91800c17/attachment.htm>


More information about the web-devel mailing list