haskell - Using Yesod.Auth.Hardcoded SiteAdmin in a hamlet template -
problem description
i've been unable compiling example of using yesod.auth.hardcoded. problem in trying interrogate user in hamlet template. foundation.hs
set per documentation in link hardcoded. handler looks this:
gethomer :: handler html gethomer = uid <- maybeauthid (widget, enctype) <- generateformpost . renderbootstrap3 bootstrapbasicform $ blurbform nothing currentpost <- rundb $ selectfirst [] [desc blogid] currentblurb <- rundb $ selectfirst [] [desc blurbid] defaultlayout $ settitle "my site" addscriptremote "https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js" addscriptremote "https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.2.0/js/collapse.js" $(widgetfile "homepage")
my site compiles , renders happily until try useful uid
being assigned in do
block above.
what i've tried
i've tried both $maybe
, $case
constructs in hamlet documentation. $maybe
looked this:
$maybe user <- uid <p>there's name $nothing <p>no name
this succeeded regardless of whether logged in hardcoded user.
the $case
version looked this:
$case uid $of left _ <p>there's no name $of right username <p>it worked
and failed with:
exception when trying run compile-time code: inside $case there may $of. use '$of _' wildcard. code: widgetfile "homepage" in splice: $(widgetfile "homepage")
question(s)
am setting uid
correctly in handler code and, if so, how should access hardcoded sitemanager
in templates?
as posting question made me think of answer, though i'd still grateful better ones. using combination of $maybe
, $case
so:
$maybe user <- uid $case user $of left _ <p>there's no name $of right username <p>there might name of #{username} $nothing <p>no name
got me correct username. please post answer if there better way.
Comments
Post a Comment