[Haskell-cafe] Yesod a href render issue

5 views
Skip to first unread message

Thiago Negri

unread,
Aug 31, 2012, 7:14:26 PM8/31/12
to Haskell-Cafe
I'm following Yesod tutorial that gives this as the first example for
"type-safe URLs":

| getHomeR = defaultLayout [whamlet|<a href=@{Page1R}>Go to page 1!|]

Worked fine, the "a href" generated looks perfect.
Then I tried this:

| getHomeR = defaultLayout [whamlet|Hello!<a href=@{Page1R}>Go to page 1!|]

And got a "a href" referecing a URL without quotes and with no end tag
for "a", something like this:

| <html><head><title></title></head><body>Hello<a href=/page1>Go to
page 1!</body></html>

I tried in many different ways, and the only way to get it working
properly was to set the "a" tag in a line by itself:

| getHomeR = defaultLayout [whamlet|Hello!
| <a href=@{Page1R}>Go to page 1!
| |]

Is this a failure of Yesod quasiquotation or am I missing something?
I know Yesod clearly states that the best approach is to use external
files instead of quasiquotes, but as I'm making my first steps into
Yesod, I would like to use the practical embedded quasiquotes.

_______________________________________________
Haskell-Cafe mailing list
Haskel...@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

David McBride

unread,
Aug 31, 2012, 8:45:46 PM8/31/12
to Thiago Negri, Haskell-Cafe
Hamlet is whitespace sensitive like haskell and python.  If you put a tag after text, it is treated as text.

Write the <a... on the next line and it will work.

Felipe Almeida Lessa

unread,
Aug 31, 2012, 9:04:41 PM8/31/12
to David McBride, Haskell-Cafe
On Fri, Aug 31, 2012 at 9:45 PM, David McBride <toa...@gmail.com> wrote:
> Hamlet is whitespace sensitive like haskell and python. If you put a tag
> after text, it is treated as text.
>
> Write the <a... on the next line and it will work.

Another option is to manually put the closing </a> when the tag is in
the middle of the line. This is especially useful for tags such as
<em> or <strong>, e.g.

This is <strong>very</strong> important!

vs.

This is #
<strong>very
\ important!

Cheers,

--
Felipe.
Reply all
Reply to author
Forward
0 new messages