Arc Forumnew | comments | leaders | submitlogin
1 point by yariv 4320 days ago | link | parent

Typo: different -> difference.

Also, the last two parameters should be in a list, i.e.

said(_Req) -> form(fun(Data) -> link(["you said: ", arg(Data, "foo")], "click here") end, [input("foo"), submit()]).



1 point by partdavid 4319 days ago | link

I've been thinking about this challenge in terms of Erlang idioms and worked up a (very) minimal web framework using yaws. With SPEWF < http://code.google.com/p/spewf/ > this might look like:

   handle(_, [{said, Value}|_]) ->
        {Value, {ehtml, {a, [{href, self}], "click me"}}};
   handle(S, [_|R]) ->
        handle(S, R);
   handle([], []) ->
        {[], {ehtml, {form, [{action, self}],
                            [{input, [{type, "text"},
                                      {name, "said"}, {size, 50}], []},
                             {input, [{type, "submit"}]}]}}};
   handle(S, []) ->
        {S, {ehtml, {p, [], io_lib:format("you said: ~s", [S])}}}.
Like many of the other examples, it's lacking the clever HTML generation.

-----