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
2
votes
1 answer

Yesod: How to build parameterized routes

I am try to pass a parameter to a route at runtime inside a hamlet template. buildFeedRow :: Item [Attribute Text] -> GWidget a a () buildFeedRow item = do let f = unpackItem item u :: Text = url f [whamlet| …
Steve Severance
  • 6,611
  • 1
  • 33
  • 44
2
votes
1 answer

Using Licius + Hamlet + Julius in Servant

I would like to use Shakespearean Templates (Licius + Hamlet + Julius) from the Yesod.But I have some difficulty with this. The following code from enter link description here works: type TestAPI = "tests" :> Get '[JSON] [Test] :<|> "test"…
QSpider
  • 537
  • 2
  • 10
2
votes
2 answers

Call a function inside a hamlet file

I have writen a small language lookup with a function getValue :: String -> String -> String getValue lang key = ( head $ filter ((== key) . head) langData) !! getLangIndex lang now i want to call this lookup function inside a hamlet…
Xlaech
  • 456
  • 3
  • 19
2
votes
1 answer

How to combine "details" from a separate query in a list in Hamlet?

I'd like to display a list of items in a webpage, along with associated details from a separate table (with a many-to-one relationship). How do I do this in Yesod? I am using the default scaffolding. The upshot is that runDB cannot be nested in a…
jpaugh
  • 6,634
  • 4
  • 38
  • 90
2
votes
1 answer

Render hamlet template from file

Assuming I have the following shakespeare template code: $doctype 5

This is a test
Value of test variable: #{testVariable} in the file mytemplate.hamlet. How can I render it using shamletFile without…
Uli Köhler
  • 13,012
  • 16
  • 70
  • 120

2
votes
1 answer

$if expressions in Hamlet

I have a condition in my Hamlet template that looks like this: $if (&&) (index == 0) (row == 0) which works fine. If I try to re-write this as the more natural $if (index == 0) && (row == 0) or $if ((index == 0) && (row == 0)) then it…
Timwi
  • 65,159
  • 33
  • 165
  • 230
2
votes
0 answers

Generation HTML page content in Yesod using Data.Tree

Hi There! Say I have a gigantic multi-node Tree in Haskell where each node contains HTML content of each page. Using Yesod, the user will access a web page with the URL /myPage and the Handler getMyPageR :: Handler Html will be called. What I…
kolam
  • 731
  • 4
  • 17
2
votes
1 answer

hamlet templates and deconstructing data in $forall : why it doesn't bring deconstructed members in scope?

In Yesod, using whamletFile function in a route handler, I have issue deconstructing records in the $forall construct. I have this data record: data Foo a = Foo (a, Int, Int) in hamlet template file, I itterate over an instance of [Foo] and try to…
smoothdeveloper
  • 1,972
  • 18
  • 19
2
votes
0 answers

How to include one external hamlet file inside another?

My question is quite simple: How can I include one external hamlet file into another external hamlet file? Let's say I have a header or footer that's shared amongst every page, does it have to be 'assembled in haskell' like mentioned here, or can it…
jcristovao
  • 554
  • 2
  • 12
2
votes
1 answer

How does one apply HamletSettings to a quasiquote in Hamlet?

Background: I am studying how Hamlet works, with WAI, but without Yesod. I have no grasp of Template Haskell, but before I dive into it, I am wondering if there is a known/quick solution for this task. Specifics: I would like to know how to change…
jerng
  • 499
  • 6
  • 13
2
votes
1 answer

Use of Hamlet's $case with records and ADTs

It would seem that Hamlet's $case expression should be remarkably useful, but I can't figure out how one would match against an record type with multiple constructors short of pattern matching (with a unique name) each of the fields. Say I have a…
bgamari
  • 5,913
  • 1
  • 18
  • 21
2
votes
1 answer

Test if User is Logged in In Hamlet template

I want to test if the user is authenticated and show a "log in" or "log out" link depending on the state. So far I have $maybe muid <- maybeAuthId Logout $nothing Login but I get an…
oh_cripes
  • 107
  • 1
  • 1
  • 7
2
votes
1 answer

How do I use StaticRoute values in Hamlet?

The TH call $(staticFiles "static") dumps a load of values of type StaticRoute. Hamlet typesafe URLs (i.e. @{...}) take values of type Route Foo, where Foo is my foundation. There must be a way of using the StaticRoute values as URLs in Hamlet. …
jameshfisher
  • 34,029
  • 31
  • 121
  • 167
2
votes
1 answer

id property in yesod

In yesod, we can specify the class attribute like so:
==>
Is there an analog for id? For example, something like:
==>
Clark Gaebel
  • 17,280
  • 20
  • 66
  • 93
2
votes
3 answers

Trying to send an email in yesod using hamlet

I am building a survey site in Yesod (0.10) and am getting lost in the types. Here is a simplified version on what I am trying to do. invitation url = do render <- getUrlRender return $ renderHtml [hamlet|

Dear foo, please take our

MattoxBeckman
  • 3,682
  • 2
  • 20
  • 16