Zotonic
Zotonic
zotonic@conference.zotonic.com
Sunday, 14 July 2013< ^ >
Arjan has set the subject to: Zotonic - The Erlang Web Framework & CMS
Room Configuration

GMT+2
[01:37:11] cillian.deroiste leaves the room
[06:47:26] w.a.barnhill leaves the room
[08:55:06] simon.smithies joins the room
[09:25:10] simon.smithies leaves the room
[10:58:21] arcusfelis joins the room
[12:02:36] arjan joins the room
[12:16:05] cillian.deroiste joins the room
[13:35:36] cillian.deroiste leaves the room
[13:35:37] cillian.deroiste joins the room
[14:27:08] <cillian.deroiste> Hi, I'm having a hell of a time trying to figure out how to return a page in response to a POST request.
[14:27:48] <cillian.deroiste> Facebook allows you to embed a page (in an iframe) and have it appear in various places. But they insist on requesting it with a POST
[14:28:20] <cillian.deroiste> I've added a custom controller which includes POST in the allowed_methods function
[14:28:52] <cillian.deroiste> I can return a bare string in a process_post method with: {true, wrq:append_to_resp_body('ok', ReqData), Context}.
[14:29:50] <cillian.deroiste> but I can't figure out how to render a page and send that back instead of the string
[14:54:15] <arjan> z_render:template("page.tpl", [{id, Id}], Context)
[14:54:23] <arjan> will render a .tpl file to a string with the given arguments
[14:54:26] <arjan> from the top of my head
[14:54:38] <arjan> oh no, it's
[14:54:51] <arjan> z_template:render("page.tpl", ...
[14:54:53] mawuli.ypa joins the room
[14:55:42] arjan leaves the room
[14:59:52] w.a.barnhill joins the room
[15:07:48] <cillian.deroiste> Hmm .. I guess I misunderstood, that returns a list of bitstrings, and if I return {true, wrq:append_to_resp_body(Output, ReqData), Context} I get an error
[15:08:11] <cillian.deroiste> {error,{error,badarg,[{erlang,iolist_to_binary,
[15:09:03] mawuli.ypa leaves the room
[15:51:52] <cillian.deroiste> indeed {true, wrq:append_to_resp_body(["ok","ey"], ReqData), Context}. returns "okey", so it's fine with a list
[16:29:40] <cillian.deroiste> aha! z_template:render doesn't seem to substitute all the variables, e.g. it contains {script,[]}
[16:42:38] <cillian.deroiste> woohoo!: {Rendered, Ctx} = z_context:output(Tmpl, Context)
[20:46:04] w.a.barnhill leaves the room
[21:40:34] w.a.barnhill joins the room
[21:48:38] simon.smithies joins the room
[21:57:21] w.a.barnhill leaves the room
[22:09:03] mawuli.ypa joins the room
[22:11:51] arcusfelis leaves the room
[23:58:25] simon.smithies leaves the room
Powered by ejabberd Powered by Erlang Valid XHTML 1.0 Transitional Valid CSS!