2

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?

Xlaech
  • 456
  • 3
  • 19

2 Answers2

3

You can use any Haskell expression which is in scope using #{} interpolation. Just make sure you function produces something of ToHTML instance.

arrowd
  • 33,231
  • 8
  • 79
  • 110
0

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).

Janthelme
  • 989
  • 10
  • 23