kees Bleijenberg
unread,Dec 17, 2021, 8:09:52 AM12/17/21Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Yesod Web Framework
This is what I do for generating options in a select in Hamlet:
-- as is [0,1,2,3] :: [Int]
-- isOne is a function from Int -> Bool
<select>
$forall a <- as
$if isOne a
<option value=#{show a} selected> #{show a} (1)
$else
<option value=#{show a}> #{show a} (2)
This works. I get a select with 1 selected.
When I create a option almost always line 1 is equal to line 2, but the first line contains the word "selected"
Idea: I write the function
selected :: Bool -> Text
selected True = "selected"
selected False = ""
and change the code to
<select>
$forall a <- as
<option value=#{show a} #{selected $ isOne a}> #{show a}
Unfortunately, now the generated Html is:
<select><option value="0" id="{selected" $ isOne a}> 0</option>
<option value="1" id="{selected" $ isOne a}> 1</option> ....
Not what I want.
What is going wrong en how can I do this better?
Kees