Hello, does Lucid allow to compute html parts?
To clarify, in usual Haskell, it is possible to define a function as:
f x = y + z
where
y = 2*x
z = x*x
But, in Lucid templates, it seems to only be possible some simpler calculations:
getPage :: String -> Html ()
getPage msg = html_ $ do
p_ (toHtml $ msg)
I would like to know if it is possible to use a “where” clause in Lucid html generation for complex computations.
Sure, you can put a where
clause under the line that starts with p_
.
1 Like
I am interested about more complex cases, for example, how to implement something like this:
div_ $ do myElem
where myElem = p_ "hello, Lucid Where clause"
This raises a parse error.
Why not just:
let myElem = p_ "hello, Lucid Where clause"
...
in div_ $ do myElem
1 Like
Actually, this “let - in” combination works on the html level. Probably, also the where combination would probably work too.