Thanks for the good writing. We should make an example of integrating the 
two.

On Tuesday, 2 April 2013 05:01:10 UTC-5, Arnon Marcus wrote:
>
> EmberJS is one of the most comprehensive MVC frameworks of the day - it's 
> "batteries included" (like web2py).
>
> It is inspired by Ruby-on-Rails, in terms of preferring 
> "convention-over-configuration" (like web2py).
>
> It has "sane defaults" for the high-level architecture, so it could 
> require minimal code for standard stuff (like web2py).
>
> The MVC naming-structure is somewhat different, but essentially the same 
> components exist as in web2py.
>
>  
>
> *The Router:*
>
>  
>
> Like in web2py, there is a convention for mapping controllers to views, 
> but unlike web2py, routing (the mapping of URLs to code) is done explicitly.
>
> It is analogous to web2py's "routs.py" file.
>
> The router is doing client-side routing, translating code to URL and 
> vice-versa. 
>
>  
>
> *The Model:*
>
> * *
>
> Firstly, there is an extension called EmberData that works holistically 
> with EmberJS (but can be used without it) that does all the 
> front-end/back-end synchronization.
>
> It is analogues to web2py's database-abstraction-layer (DAL) architecture, 
> for supporting multiple optional back-ends, and converting data to an ORM 
> (object-relation-model).
>
> As in RoR (ruby-on-rails), the conversion is done via "Adapters" which are 
> like web2py's DAL-drivers.
>
> In RoR it outputs what's known as "Active-Records" - essentially, objects 
> that map to the back-end, and "know" how to save/update data back.
>
> In EmberData you would write:
>
>                 model  = DS.Store.create()
>
> Where in web2py you would write:
>
>                 db = DAL(<connection-string>)
>
> The data received from the backend, after being converted to ORM objects, 
> is known as "Records".
>
> What is called "Record" in EmberData is essentially like a "Row" object in 
> web2py, and similarly a "RecordArray" in EmberData is analogous to a "Rows" 
> object in web2py.
>
>  
>
>  *The View:*
>
>  
>
> In EmberJS, a "view" is somewhat different from what a "view" in web2py, 
> as it deals with user-interaction event-handeling.
>
> However, EmberJS uses "Templates" which are essentially what web2py's 
> "views" are. It even uses very similar templating  language with a 
> squirrely-brackets ("{{<somthing>}}").
>
> It has similar uses, so where in web2py, a controller "passes" data to the 
> view, in EmberJS a controller "binds" data to a template.
>
> The difference here is that because it is all client-side, EmberJS can do 
> data-binding - whenever a controller's bound-data changes, the template 
> automatically updates itself in the UI.
>
> Additionally, in EmberJS there are special names that do special things 
> inside a template.
>
> For example:
>
> Where in web2py, the "layout" may have something like:
>
>                 ...
>
>                 <header>...</header>
>
>                 ...            
>
>                 {{include}}
>
>                 ...
>
>                 <footer>...</footer>
>
>                 ...
>
> In ember it would be:
>
>                 ...
>
>                 <header>...</header>
>
>                 ...            
>
>                 {{outlet}}
>
>                 ...
>
>                 <footer>...</footer>
>
>                 ...
>
> Essentially meaning "everything else inside this template, put here"...
>
>  
>
> Similarly, where in web2py you would write:
>
>                 ...
>
>                 {{if someBoolean}}
>
>                 <div>{{someBoolean}}</div>
>
>                 {{pass}}
>
>                 ...
>
>                 <ol>
>
>                                 {{for a in someArray}}
>
>                                 <li>{{a}}</li>
>
>                                 {{pass}}
>
>                 </ol>
>
>                 ...
>
> In EmberJS it would look something like this:
>
>                 ...
>
>                 {{#if someBoolean}}
>
>                 <div>{{someBoolean}}</div>
>
>                 {{/if}}
>
>                 ...
>
>                 <ol>
>
>                                 {{#each a in someArray}}
>
>                                 <li>{{a}}</li>
>
>                                 {{/each}}
>
>                 </ol>
>
>                 ...
>
> Also, where in web2py the mapping of views to controllers is done via 
> folder-structure + file-naming,
>
> in EmberJS it is done via name-mapping of controller-object-name and 
> template-object-name.
>
>  
>
>  *The Controller:*
>
> * *
>
> In web2py a controller automatically maps to a sub-set of the URL, and may 
> have many functions called "Actions", which each is mapped to a view.
>
> In EmberJS this is further generalized in the "Router", which can contain 
> many nested "Routs", each mapped to a single "controller" via the router 
> and/or naming-convention.
>
> So an EmberJS "Rout" is analogous to a web2py "Controller", and an EmberJS 
> "Controller" is analogous to a web2py "Controller-Action".
>
> This is offers a more flexible hierarchy for the application, as a router 
> can "nest" routs as deeply as you want.
>
>  
>
>  
>
> Here are some great (and funny) videos about Ember (watching in order is 
> advisable):
>
>  
>
> EmberData <http://youtu.be/_6yMxU-_ARs>
>
>  
>
> EmberJS <http://youtu.be/4Ed_o3_59ME> (you can skip the live-demo part in 
> the middle, it's not very clear here..)
>
>  
>
> Live Demo <http://youtu.be/Ga99hMi7wfY> (This one is very clear.)
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to