[erlang-questions] ANN: ezwebframe - an easy web framework
Joe Armstrong
erlang@REDACTED
Thu Dec 13 12:13:42 CET 2012
On Thu, Dec 13, 2012 at 11:45 AM, Loïc Hoguin <essen@REDACTED> wrote:
> On 12/13/2012 11:17 AM, Joe Armstrong wrote:
>
>> ezwebframe
>> ==========
>>
>> https://github.com/joearms/**ezwebframe<https://github.com/joearms/ezwebframe>
>>
>> Pronounced "Easy web frame."
>>
>> About
>> =====
>>
>> Ezwebframe attempts to make web programming just a little bit easier.
>>
>> From Erlang point of view the browser *is* an Erlang process.
>>
>> Assume we have a web page populated with divs. For example:
>>
>> <div id="a">
>> ...
>> </div>
>>
>> <div id="b">
>> ...
>> </div>
>>
>> Erlang thinks the browser is a process. To fill div a with HTML an
>> Erlang process evaluates the command:
>>
>> Browser ! [{cmd, fill_div}, {id, a}, {txt, B}]
>>
>> Where B is a binary containing HTML.
>>
>
> Why not implement this for the modifications instead, though? It's well
> defined and works very well: http://taconite.sourceforge.**net/<http://taconite.sourceforge.net/>
>
I don't understand ...
What actually happens is this ...
Browser ! [{cmd, fill_div}, {id, X}, {txt, Y}]
gets converted to the JS function call
fill_div(o)
where o = {cmd:'fill_div', id:X, txt:Y}
and I have pre-defined
fill_div as
function fill_div(o){
$("#" + o.id).html(o.txt);
}
(assumes jQuery)
If you want to extend the system you say
Browser ! [{cmd,new_cmd},{x,...},{y,...}]
and supply a new js function new_cmd(o) which will be called with
o = {cmd:'new_cmd'},{x,...},...}
This provides an extensible abstract interface between the browser and
Erlang.
Websockets + JSON + a tiny bit of glue = good stuff
/Joe
>
> Don't need to be XML of course, but the actions defined are a good start
> of what frontend people usually want.
>
So if you want an action kick_ball I'd write
Browser ! [{cmd,kick_ball}, {velocity, 23}, ...]
in Erlang, and provide some JS to do the kicking
function kick_ball(o){
...
}
which would be called with o = {cmd:'kick_ball', velocity:23, ...}
/Joe
>
> --
> Loďc Hoguin
> Erlang Cowboy
> Nine Nines
> http://ninenines.eu
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121213/4d318412/attachment.htm>
More information about the erlang-questions
mailing list