Reputation: 466
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 file.
Is this possible and how do i have to change the function to make it callable?
Upvotes: 2
Views: 102
Reputation: 999
Something like this should work:
myhamlet key lang = [hamlet|
<h1> for key = #{key}, lang = #{lang}, value = #{getValue lang key}
|]
... or in a .hamlet file :
<h1> for key = #{key}, lang = #{lang}, value = #{getValue lang key}
(assuming that key
and lang
are in scope).
Upvotes: 0
Reputation: 34401
You can use any Haskell expression which is in scope using #{}
interpolation. Just make sure you function produces something of ToHTML
instance.
Upvotes: 3