Questions tagged [hamlet]

Hamlet is a type-safe framework for generating HTML code from Haskell

Hamlet is a type-safe tool for generating HTML code in Haskell. It is used in the Yesod web framework .

86 questions
4
votes
1 answer

How to link to a static file in Hamlet?

I looked at a previous question that sounds like it’s the same question, but it seems to skip over a part that I must be missing. I added the import Settings.StaticFiles line at the top of the handler file. I copied a file called chunk.png into the…
Timwi
  • 65,159
  • 33
  • 165
  • 230
4
votes
1 answer

How to use $maybe in hamlet

In Yesod, I've got a form that populates the type data Field = Field Text Text text deriving Show When I write the hamlet html to display it, I'm running into the problem that Field is wrapped up in Maybe Maybe Field. So in hamlet I'm trying to…
HHC
  • 2,513
  • 2
  • 18
  • 26
4
votes
2 answers

Using UTCTime with Hamlet

I am using Yesod on my first site and I have a list of news items: NewsItem date UTCTime default=CURRENT_TIME title String content String author String which are retrieved in my handler: newsitems <- runDB $ selectList []…
Jeffrey Drake
  • 805
  • 10
  • 26
4
votes
1 answer

Yesod: Is it possible to to iterate a haskell list in Julius?

I have a list of coordinates that I need to put on map. Is it possible in julius to iterate the list ? Right now I am creating an hidden table in hamlet and accessing that table in julius which does not seem to be an ideal solution. Could some one…
Akshat
  • 577
  • 3
  • 6
3
votes
1 answer

Always `$newline never` in Yesod

$newline never in Hamlet allows us to minify the HTML code. If we set it in a parent widget, it takes effect on it but not on the child widgets. So we have to set $newline never to all of the widgets when we want to minify the whole code. This isn't…
Marronnier
  • 389
  • 2
  • 10
3
votes
0 answers

Hamlet quasiquoter (Haskell): Allowed syntax in if-elseif-else expressions

The Hamlet quasiquoter allows if-then-else syntax like [hamlet| $if 3 < 4 Three is less than 4. $elseif "a" == "b" 'a' equals 'b'. $else Nothing worked out. |] However, I find that if I replace the test "a" == "b" with…
3
votes
1 answer

How generate a token widget on Yesod?

I have the next problem with Yesod. I want to make my own form on my HTML because I want my own tags and labels, but the problem is how can I do that if my form is autogenerated with the next code: entryForm :: Form Post entryForm = renderDivs $…
tonylattke
  • 98
  • 7
3
votes
1 answer

How do I access a user's authentication from a hamlet template?

For example, If a nobody is logged in, I want to show them links to where they can sign up or log back in, but if a user is logged in, I want a way to let them access their profile and other information.
jalarast
  • 47
  • 5
3
votes
1 answer

Yesod's shakespearean templates (hamlet) and IO

In Hamlet, how does one uses the result of an IO operation inside #{...} ? For instance : someIO :: IO String ----------------- $with stuff <- someIO

#{stuff} Fails with No instance for (blaze-markup-0.6.0.0:Text.Blaze.ToMarkup …

gxtaillon
  • 1,016
  • 1
  • 19
  • 33
3
votes
0 answers

Error using Prelude.read in Hamlet Yesod

I get an error when I use the following Haskell code inside Hamlet Yesod: #{show $ (read "True" :: Bool)} It seems it doesn't accept ':' characters, but I actually need it. The error is the following: Handler/Game.hs:85:11: Exception when…
kolam
  • 731
  • 4
  • 17
3
votes
1 answer

Yesod Julius Interpolation of Messages

I've been using Yesod's messages system to help keep my language consistent. For example, I have a message named MsgBrand, which gets interpolated into Hamlet files with no problem. However, I am now using a JavaScript library which needs this…
nomen
  • 3,626
  • 2
  • 23
  • 40
3
votes
1 answer

Is it possible to call hamlet from JavaScript?

I'm trying to implement this nav bar on my Yesod web app. My question how should I call a hamlet file from the javascript? ..... ..... var Tabs = { 'Tab one' : 'pages/page1.html', 'Tab two' : 'pages/page2.html', 'Tab three' :…
HHC
  • 2,513
  • 2
  • 18
  • 26
3
votes
1 answer

Using Type-safe URLs with setMessage? (shamlet versus hamlet)

How do I use a type-safe url with setMessage? I want to change ... setMessage [shamlet|Warning! See Help.|] ... to a message that contains a link. From what I could gather thus far, it ought to work somehow like this ... …
Steffen
  • 289
  • 1
  • 7
3
votes
1 answer

yesod persistent: get Entity value within hamlet

let's say my config/models file looks like this: Pet name Text owner OwnerId Owner name Text I can get the pet's name like this: $forall Entity key pet <- pets #{petName pet} but how would I get an owner's name from a pet…
user316146
  • 1,307
  • 1
  • 12
  • 19
3
votes
1 answer

Use Shakespeare-text and external file

How can I convert the below example to use an external file instead of the embedded lazy text quasi quotes? {-# LANGUAGE QuasiQuotes, OverloadedStrings #-} import Text.Shakespeare.Text import qualified Data.Text.Lazy.IO as TLIO import Data.Text…
Adam Gordon Bell
  • 3,083
  • 2
  • 26
  • 53