SlideShare una empresa de Scribd logo
1 de 49
Descargar para leer sin conexión
Rendering Views in
                            JavaScript
                          The New Web Architecture

                                                            Jonathan Julian
                                                            @jonathanjulian




                                          http://www.flickr.com/photos/thelightningman/5473594295/

Sunday, July 10, 2011
@jonathanjulian
                        jonathanjulian.com
                           410labs.com
                          shortmail.com




                                  http://www.flickr.com/photos/see-through-the-eye-of-g/4283298553/
Sunday, July 10, 2011
http://talkinterior.com/modern-studio-architecture-parasite-san-paolo-bank-design-romania/
Sunday, July 10, 2011
http://www.livelygrey.com/2007/08/the_pink_white_house.html

Sunday, July 10, 2011
http://www.staff.ncl.ac.uk/roger.broughton/museum/firmware/mainframe.htm
Sunday, July 10, 2011
http://www.old-computers.com/fun/default.asp?s=56
Sunday, July 10, 2011
http://splitscreencoop.com/2010/09/10/computers-programmed-to-entertain/

Sunday, July 10, 2011
Sunday, July 10, 2011
http://www.rpm-software.com/clientserver.php


Sunday, July 10, 2011
Sunday, July 10, 2011
Sunday, July 10, 2011
http://cscie12.dce.harvard.edu/lecture_notes/2010/20100421/slide43.html
Sunday, July 10, 2011
Sunday, July 10, 2011
OMG
Sunday, July 10, 2011
                        AJAX
Sunday, July 10, 2011
The New Web Architecture




                          http://talkinterior.com/modern-studio-architecture-parasite-san-paolo-bank-design-romania/
Sunday, July 10, 2011
“The New Web Architecture”
            http://www.quirkey.com/blog/2009/09/15/sammy-js-
                  couchdb-and-the-new-web-architecture/




                           http://talkinterior.com/modern-studio-architecture-parasite-san-paolo-bank-design-romania/
Sunday, July 10, 2011
The New Web Architecture

                        Server   JSON     Client
                         REST              Views
                          db             behaviour
                        Models          Controllers




Sunday, July 10, 2011
What does it look like?



Sunday, July 10, 2011
How do you build it?



Sunday, July 10, 2011
/public
                        /public/javascripts


Sunday, July 10, 2011
/src
                        (php, ruby, python, Java,
                              ColdFusion)


Sunday, July 10, 2011
Examples



Sunday, July 10, 2011
Sunday, July 10, 2011
http://www.flickr.com/photos/hatm/5704687186/




Sunday, July 10, 2011
• DIY events
                        • DIY templates
                        • models?

Sunday, July 10, 2011
Sunday, July 10, 2011
• controller
                        • DIY views
                        • plug-ins

Sunday, July 10, 2011
(function($) {
     var app = $.sammy('#main', function() {
       this.get('#/', function(context) {
         // do whatever you need to do for #/
       });
     });
     $(function() {
       app.run('#/');
     });
   })(jQuery);


Sunday, July 10, 2011
Sunday, July 10, 2011
• models
                        • views
                        • events!
                        • ajax!

Sunday, July 10, 2011
var Note = Backbone.Model.extend({
      initialize: function() { ... },
      author: function() { ... },
      allowedToEdit: function(account) {
        return true;
      }
    });

    var Notes = Backbone.Collection.extend({
      url: '/notes'
    });

                                               fetch()
                                               save()
                                               destroy()
Sunday, July 10, 2011
var Workspace = Backbone.Controller.extend({
      routes: {
         "help":                 "help",   // #help
         "search/:query":        "search", // #search/kiwis
         "search/:query/p:page": "search"  // #search/kiwis/p7
      },
      help: function() {
         ...
      },
      search: function(query, page) {
         ...
      }
    });




Sunday, July 10, 2011
var DocumentView = Backbone.View.extend({
      events: {
         "dblclick"                : "open",
         "click .icon.doc"         : "select"
      },
      render: function() {
         $(this.el).html(this.template(this.model.toJSON()));
         return this;
      },
      open: function() {
         window.open(this.model.get("viewer_url"));
      },
      select: function() {
         this.model.set({selected: true});
      },
    });


Sunday, July 10, 2011
Rendering
                                                      Views




 http://www.flickr.com/photos/aoifemac/171476309/
Sunday, July 10, 2011
Underscore                    ICanHaz
                                                 Eco




                                                                                           EJS
                        Mustache                                Mold




                          Jaml     jquery-tmpl
                                                           Weld




                                                            Pure

                                                       http://www.flickr.com/photos/alibree/244728678/
Sunday, July 10, 2011
Underscore Template
           $('#content').html(
              _.template(
                '<h1><%= name %></h1>',
                {name: 'Foo'}
              )
           );




Sunday, July 10, 2011
Mustache Template
           $('#content').html(
              Mustache.to_html(
                '<h1>{{name}}</h1>',
                {name: 'Foo'}
              )
           );




Sunday, July 10, 2011
EJS Template
           $('#content').html(
              new EJS({
                 url: ‘my_template.ejs’
              }).render({
                 name: 'Foo'
              })
           );



Sunday, July 10, 2011
ICanHaz Template
           <script id="welcome" type="text/html">
             <h1>Welcome, {{ name }}</h1>
           </script>

           <script>
             $(document).ready(function() {
               $('#content').html( ich.welcome({name: 'Username'}) );
             });
           </script>




Sunday, July 10, 2011
• jquery-tmpl - mustache-like
                        • Jaml - not much like Haml
                        • Pure - directive-based
                        • Mold - php-like
                        • Weld - uses existing divs
                        • Eco - coffeescript, ASP-like
Sunday, July 10, 2011
javascript/templates
                        javascript/templates/user.jst
                        javascript/templates/address.jst
                        javascript/templates/post.jst
                        javascript/templates/comment.jst
                        javascript/templates/comments.jst




Sunday, July 10, 2011
window.JST.address = _.template
                ("...html...");

                window.JST.address
                ({email:'joe@example.com', name:'Joe
                Bob'});




Sunday, July 10, 2011
Sunday, July 10, 2011
BITCH, PLEASE
Sunday, July 10, 2011
http://www.flickr.com/photos/davic/3358417142/


Sunday, July 10, 2011
•   more frameworks

                        •   more templating choices

                        •   adoption of REST

                        •   HTML5

                        •   Rails 3.1 includes Sprockets and CoffeeScript OUT OF THE BOX

                        •   CouchDB over HTTP

                        •   Sproutcore

                        •   node.js

                        •   node.js



Sunday, July 10, 2011
http://www.flickr.com/photos/alykat/5284308030/
Sunday, July 10, 2011
I am @jonathanjulian




                        Thanks GothamJS!



      http://www.flickr.com/photos/alykat/5284308030/
Sunday, July 10, 2011

Más contenido relacionado

Similar a Rendering Views in JavaScript - "The New Web Architecture"

SeaJS - 跨环境模块化开发实践
SeaJS - 跨环境模块化开发实践SeaJS - 跨环境模块化开发实践
SeaJS - 跨环境模块化开发实践
lifesinger
 
Html5/CSS3 in shanghai 2010
Html5/CSS3 in shanghai 2010Html5/CSS3 in shanghai 2010
Html5/CSS3 in shanghai 2010
Zi Bin Cheah
 
LT 08 - Guilherme Silveira - Cache hipermidia
LT 08 - Guilherme Silveira - Cache hipermidiaLT 08 - Guilherme Silveira - Cache hipermidia
LT 08 - Guilherme Silveira - Cache hipermidia
DNAD
 
Searching does not mean finding Stuff - Apache Solr for TYPO3
Searching does not mean finding Stuff - Apache Solr for TYPO3Searching does not mean finding Stuff - Apache Solr for TYPO3
Searching does not mean finding Stuff - Apache Solr for TYPO3
Olivier Dobberkau
 
international PHP2011_ilia alshanetsky_Hidden Features of PHP
international PHP2011_ilia alshanetsky_Hidden Features of PHPinternational PHP2011_ilia alshanetsky_Hidden Features of PHP
international PHP2011_ilia alshanetsky_Hidden Features of PHP
smueller_sandsmedia
 
WebShell - confoo 2011 - sean coates
WebShell - confoo 2011 - sean coatesWebShell - confoo 2011 - sean coates
WebShell - confoo 2011 - sean coates
Bachkoutou Toutou
 
What python can learn from java
What python can learn from javaWhat python can learn from java
What python can learn from java
jbellis
 

Similar a Rendering Views in JavaScript - "The New Web Architecture" (20)

Changeyrmarkup
ChangeyrmarkupChangeyrmarkup
Changeyrmarkup
 
node.js for front-end developers
node.js for front-end developersnode.js for front-end developers
node.js for front-end developers
 
SeaJS - 跨环境模块化开发实践
SeaJS - 跨环境模块化开发实践SeaJS - 跨环境模块化开发实践
SeaJS - 跨环境模块化开发实践
 
Ready to Play: JavaScript / HTML5 Game Development
Ready to Play: JavaScript / HTML5 Game DevelopmentReady to Play: JavaScript / HTML5 Game Development
Ready to Play: JavaScript / HTML5 Game Development
 
Html5/CSS3 in shanghai 2010
Html5/CSS3 in shanghai 2010Html5/CSS3 in shanghai 2010
Html5/CSS3 in shanghai 2010
 
Web performance at WDCNZ
Web performance at WDCNZWeb performance at WDCNZ
Web performance at WDCNZ
 
Node conf - building realtime webapps
Node conf - building realtime webappsNode conf - building realtime webapps
Node conf - building realtime webapps
 
Javascript Views, Client-side or Server-side with NodeJS
Javascript Views, Client-side or Server-side with NodeJSJavascript Views, Client-side or Server-side with NodeJS
Javascript Views, Client-side or Server-side with NodeJS
 
A Look at the Future of HTML5
A Look at the Future of HTML5A Look at the Future of HTML5
A Look at the Future of HTML5
 
LT 08 - Guilherme Silveira - Cache hipermidia
LT 08 - Guilherme Silveira - Cache hipermidiaLT 08 - Guilherme Silveira - Cache hipermidia
LT 08 - Guilherme Silveira - Cache hipermidia
 
MongoDB at Sailthru: Scaling and Schema Design
MongoDB at Sailthru: Scaling and Schema DesignMongoDB at Sailthru: Scaling and Schema Design
MongoDB at Sailthru: Scaling and Schema Design
 
Discussing Java's Future
Discussing Java's FutureDiscussing Java's Future
Discussing Java's Future
 
Searching does not mean finding Stuff - Apache Solr for TYPO3
Searching does not mean finding Stuff - Apache Solr for TYPO3Searching does not mean finding Stuff - Apache Solr for TYPO3
Searching does not mean finding Stuff - Apache Solr for TYPO3
 
Pycon2011 android programming-using_python
Pycon2011 android programming-using_pythonPycon2011 android programming-using_python
Pycon2011 android programming-using_python
 
The Fast, The Slow and the Lazy
The Fast, The Slow and the LazyThe Fast, The Slow and the Lazy
The Fast, The Slow and the Lazy
 
international PHP2011_ilia alshanetsky_Hidden Features of PHP
international PHP2011_ilia alshanetsky_Hidden Features of PHPinternational PHP2011_ilia alshanetsky_Hidden Features of PHP
international PHP2011_ilia alshanetsky_Hidden Features of PHP
 
WebShell - confoo 2011 - sean coates
WebShell - confoo 2011 - sean coatesWebShell - confoo 2011 - sean coates
WebShell - confoo 2011 - sean coates
 
Edted 2010 Dicas de Web
Edted 2010 Dicas de WebEdted 2010 Dicas de Web
Edted 2010 Dicas de Web
 
When?, Why? and What? of MongoDB
When?, Why? and What? of MongoDBWhen?, Why? and What? of MongoDB
When?, Why? and What? of MongoDB
 
What python can learn from java
What python can learn from javaWhat python can learn from java
What python can learn from java
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 

Rendering Views in JavaScript - "The New Web Architecture"