Thiago Negri | 1 Sep 01:14 2012
Picon

Yesod a href render issue

I'm following Yesod tutorial that gives this as the first example for
"type-safe URLs":

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

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

| getHomeR  = defaultLayout [whamlet|Hello!<a href= <at> {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= <at> {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.
David McBride | 1 Sep 02:45 2012
Picon

Re: Yesod a href render issue

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.

On Fri, Aug 31, 2012 at 7:14 PM, Thiago Negri <evohunz <at> gmail.com> wrote:
I'm following Yesod tutorial that gives this as the first example for
"type-safe URLs":

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

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

| getHomeR  = defaultLayout [whamlet|Hello!<a href= <at> {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= <at> {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
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe <at> haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
Felipe Almeida Lessa | 1 Sep 03:04 2012
Picon

Re: Yesod a href render issue

On Fri, Aug 31, 2012 at 9:45 PM, David McBride <toad3k <at> 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.

Gmane