Context
I generated a standard email template via the IDE. Since I want to dynamically build an HTML table within the email, I added a function that takes a list and returns HTML. However, calling it from within the email's main [hsx|...|]
results in the error:
Couldn't match type ‘context’ with ‘ControllerContext’
arising from a functional dependency between constraints:
‘?context::ControllerContext’
arising from a use of ‘renderList’ at Admin/Mail/Accounts/Report.hs:(16,35)-(47,6)
‘?context::context’
arising from the type signature for:
IHP.MailPrelude.html :: forall context.
(?context::context, ConfigProvider context) =>
...
The function returning Html
itself compiles fine, but calling it from within the instance's [hsx|...|]
results in a compiler error.
The called function can have no arguments and the result is the same. What triggers it is when the function returns Html
. String
or Text
is fine.
Using IHP Pro 1.0.0.
Example
module Admin.Mail.Static.Test where
import Admin.View.Prelude
import IHP.MailPrelude
data TestMail = TestMail { user :: User }
instance BuildMail TestMail where
subject = "Subject"
to TestMail { .. } = Address { addressName = Just "Firstname Lastname", addressEmail = "[email protected]" }
from = "[email protected]"
html TestMail { .. } = [hsx|
Hello World
{renderFoo}
|]
renderFoo :: Html
renderFoo = [hsx|foo|]
Question
I can use functions to generate snippets of HTML in other (non-email) views with no problem so why does it not work here?