You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need a template Haskell function to embed the html templates (generated from the .pug files) inside a normal Haskell function.
I imagine this would look very similar to Yesod's widgetFile function (or other shakespeare template Haskell functions).
The function should do the following actions:
read the .html template from disk
figure out what variable names the template is looking for
wrap up all the values available in the function
check to make sure the template isn't asking for any variables that don't exist in the function
splice in the code for actually rendering the template
It would be best if we could make it so that GHC fails to compile if the template can't be rendered. However, from looking at the documentation of EDE, I'm not sure if it provides the capability to statically determine what variables a given template needs.
For example, imagine we had a template called adminUser_admin_store_create.html that looks like this:
We should be able to write handlers that look like this:
foo::Int
foo =3
storeCreate
::forallxsnm. ( ContainsAdminSessionnxs
, Monadm
)
=>ActionCtxT (HVectxs) m()
storeCreate =do-- get the admin's email from the session cookie
(AdminSession email) <- getAdminEmail
let bar ="hello"$(kucipongTemplate "adminUser_admin_store_create")
This would ideally expand to something like this:
storeCreate
::forallxsnm. ( ContainsAdminSessionnxs
)
=>ActionCtxT (HVectxs) m()
storeCreate =do-- get the admin's email from the session cookie
(AdminSession email) <- getAdminEmail
let bar ="hello"let (values ::Object) = fromPairs [ "foo".= foo, "bar".= bar, "email".= email ]
(template ::Template) =-- the following should happen at compile time: loadTemplateFromFile "adminUser_admin_store_create"
(renderedHtml ::Text) <- unsafeTemplateToHtml $ render template values
html renderedHtml
@arowM Let me know if you start on this. I might get to it next Sunday or Monday (either 2016/09/18 or 2016/09/19).
The text was updated successfully, but these errors were encountered:
We need a template Haskell function to embed the html templates (generated from the
.pug
files) inside a normal Haskell function.I imagine this would look very similar to Yesod's widgetFile function (or other
shakespeare
template Haskell functions).The function should do the following actions:
.html
template from diskIt would be best if we could make it so that GHC fails to compile if the template can't be rendered. However, from looking at the documentation of EDE, I'm not sure if it provides the capability to statically determine what variables a given template needs.
For example, imagine we had a template called
adminUser_admin_store_create.html
that looks like this:We should be able to write handlers that look like this:
This would ideally expand to something like this:
@arowM Let me know if you start on this. I might get to it next Sunday or Monday (either 2016/09/18 or 2016/09/19).
The text was updated successfully, but these errors were encountered: