
On Sat, Feb 12, 2011 at 11:59 PM, Rafael Cunha de Almeida
Hello,
From what I could gather, the way to create a link to a static page, like a picture is:
StaticR $ StaticRoute ["figure.png"] []
I wanted to add a static picture in my site's template so I added
to my template. Unfortunately, that didn't work. It seems like creating lists inside @{} or even #{} is impossible. For instance
#{head ["test"]}
doesn't work either.
Is that a bug? Or is it how it's supposed to work?
You could go either way on that one. The content of an interpolation
is specifically *not* a fully-powered Haskell expression. The question
is what syntax do we want to include. I had not thought of including
list notation, and I don't see any technical barrier to adding it. As
with most template systems, Hamlet needs to strike a balance between
power and simplicity: I could go either way on this specific one.
However, for your use case, I would recommend a different approach:
Yesod.Helpers.Static provides a Template Haskell function calls
staticFiles. If you include it at the top level of your code like
this:
staticFile "static"
It will create an identifier for each and every file in your static
folder. In that case, you could replace your Hamlet code with:
I'm open to discussion regarding adding list notation to interpolations.
Michael